Mail Archives: djgpp/1996/10/12/16:28:32
mrichman AT cybernex DOT net wrote:
: Is it safe to assume that all pointer variables take up the same
: number of bytes, or is that compiler dependent.
If you're writing really portable code, it's not safe to assume anything.
If you make a #define at the start of your source, e.g.
#define POINTER_SIZE sizeof(*void)
then use this, e.g.
int *my_array[20];
for (int a=0;a<20;a++)
printf("%d\n",*(my_array+a*POINTER_SIZE));
then when you compile on a different platform the multiplier will be
correctly adjusted.
Of course, it's much simpler to write "my_array[a]", but I presume you
don't want to do this for some reason.
George Foot
- Raw text -