From: Szymon Guz on
Hi,
I've got some maybe stupid questions but I don't understand some things:

1. Is there a pointer like (void *) from C that points to anything ?

2. Is there a universal (like above) pointer for procedure|function that
can point to any kind of procedure|funcion ?

regards
Szymon Guz
From: Gene on
The package System has an Address type with comparison operations
defined, and the package Address_To_Access_Conversions supports
conversions between addresses and pointers.

With the loss of some portability, you can also use
Unchecked_Conversion to turn one kind of pointer to another, so you can
set up your own "void*" equivalent type and convert to/from specific
pointers.

A universal pointer to function/procedure pointer is a marginally
useful and very dangerous idea. But on most architectures you can use
unchecked conversions to implement this kind of thing and get away with
it.

From: tmoran on
> 1. Is there a pointer like (void *) from C that points to anything ?
>
> 2. Is there a universal (like above) pointer for procedure|function that
> can point to any kind of procedure|funcion ?
No. But in both cases you can do an explicit Unchecked_Conversion to
convert a pointer to one thing into a pointer to something else. You are
then explicitly telling the compiler, and future maintainers of your
program, something like "yes, I know I'm calling a function that expects
two Floats with just a single Character, but I've thought about it and
it's correct in this case."
From: Stephen Leake on
Szymon Guz <alpha(a)skynet.org.pl_WITHOUT> writes:

> Hi,
> I've got some maybe stupid questions but I don't understand some things:
>
> 1. Is there a pointer like (void *) from C that points to anything ?
>
> 2. Is there a universal (like above) pointer for procedure|function
> that can point to any kind of procedure|funcion ?

As others have said, the short answer is "no".

However, depending on what you really want to do, there are ways to
define one pointer that can point to different functions at different
times.

One way is a simple 'access subprogram type.

Another is class wide programming on an inheritance type heirarchy.

Can you say something about what you are trying to do (assuming it's
more than "make Ada look like C")?

--
-- Stephe
From: Steve on
"Szymon Guz" <alpha(a)skynet.org.pl_WITHOUT> wrote in message
news:djp1tm$186k$1(a)node3.news.atman.pl...
> Hi,
> I've got some maybe stupid questions but I don't understand some things:
>
> 1. Is there a pointer like (void *) from C that points to anything ?
>
> 2. Is there a universal (like above) pointer for procedure|function that
> can point to any kind of procedure|funcion ?
>
> regards
> Szymon Guz

There are ways of doing both.

If you're programming in Ada you rarely (if ever) need to use them. The
only cases I have used them is in interfacing with other languages.

Your question is indicative of a C way of thinking.

Tell us a little more about what you're trying to do, and perhaps we can
suggest an approach using an Ada way of thinking.

Steve
(The Duck)