[Info-vax] Compatibility and 64-bit

JF Mezei jfmezei.spamnot at vaxination.ca
Sun Mar 15 13:37:38 EDT 2015


On 15-03-15 03:08, David Froble wrote:

> About the string descriptors ....


Question:

Say i have a C program.

I define

mydescriptor struct dsc$descriptor ;  (forgot the actial precise name).

That descriptor contains (from memory, pardon lack of precision)

char type;
char class;
short lenght;
void *pointer ;   (or is it unsignec char *pointer ?)


Why would my program care whether "pointer" was allocated as 4 or 8 bytes ?

If the program is compiled with a switch that makes all pointers 64
bits, then all my operations to move pointers around should be 64 bits
and this is transparent to me.

If I dynamically allocate memory to make an array of descriptors, then I
will likely use  sizeof(struct dsc$descriptor) when calculating how much
memory to allocate, so whether compiled in 32 or 64 bits, the code will
still work.

And when I manipulate a pointer, I am expected to always use pointer
variables, right ?  I am NOT supposed to move a pointer to an integer,
have fun with it as integer and then move it back to a pointer variable,
right?

Ever since VMS started to support both 32 and 64 bits, I have been weary
of assuming the size of any variable and always use sizeof when I need
to knwo it size.

Yeah, when dealing with integers, you want to make sure you have the
right incantation to have the right bit size. For instance, for VMS
time, you can safely use a quadword, but if you know the language well
enough, you can also allocate a 64 bit integer and do the math directly
to it , instead of calling the routines that add/subtract time.

But for pointers, I am not sure I understand where the problem is.



More information about the Info-vax mailing list