Mail Archives: djgpp/1997/05/23/09:34:56
On Thu, 22 May 1997 17:52:02 -0600, lenny AT netvision DOT net DOT il wrote:
>Erik,
>
>Thanks for your help. The cast (void *) did the trick.
>
>However, isn't it strange that the djgpp compiler lacks such a basic
>function that would give it the ability to print out memory addresses
>(i.e. no member function ostream::operator <<(long *))?
Actually no it's not djgpp. The iostream is an ANSI/ISO standard and
djgpp tries to stay as close to the standard as possible (as all "gnu"
products do). Any compiler supporting a ostream::operator << (long *)
is strctly speaking not ANSI compatible. Besides why should it have
to support all the different pointer types. Consider this:
struct point
{
int x;
int y;
}
...
cout << &pointvar;
If you wanted to print the address of this structure you would have
to overload the << operator to work with point*. This doesn't make
any sense because an address is an address no matter what it is
pointing to. So why not just overload the generic void* and type cast
any other pointers to void*. Makes alot of sense to me. You don't
want to have to overload for every pointer type you may ever encounter
do you?
And you can print out an address with printf (...). Do it like this:
printf ("%p", &number);
or any type. It is taken to be implicitly void here sorta.
Lonnie McCullough
lonniem AT cs DOT utexas DOT edu
- Raw text -