the allocation of structure members in Compaq C v6.5 for openVMS system
very important about the size | ||
|
the allocation of structure members in Compaq C v6.5 for openVMS system
Size of structure members (very important!)
OS is OpenVMS (TM) Alpha Operating System(Version V7.3-2),I had made a program for testing:
#include
void main()
struct test{
struct test4{
float e; // 4 bytes
printf("abc = %d n",sizeof (abc));
}
ca *.c //ca="CC/FLOAT=IEEE_FLOAT/INCLUDE_DIRECTORY=(???ignored)/LIST"
link *
link.com:
$ SET VER
the result is :
abc = 12
If under turbo c 2.0 & window xp :
pattern size
char 1 byte
int 2 bytes
unsigned int 2 bytes
signed int 2 bytes
float 4bytes
double 8 bytes
#pragma [no]member_alignment Directive
By default, Compaq C for OpenVMS VAX systems does not align structure members on natural boundaries; they are stored on byte boundaries (with the exception of bit-field members).
By default, Compaq C for OpenVMS Alpha systems does align structure members on natural boundaries.
The #pragma member_alignment preprocessor directive can be used to force natural-boundary alignment of structure members. The #pragma nomember_alignment preprocessor directive restores byte-alignment of structure members.
This pragma has the following formats:
When #pragma member_alignment is used, the compiler aligns structure members on the next boundary appropriate to the type of the member, rather than on the next byte. For example, a long variable is aligned on the next longword boundary; a short variable is aligned on the next word boundary.
Consider the following example:
When this example is executed, it shows the difference between #pragma member_alignment and #pragma nomember_alignment .
Once used, the member_alignment pragma remains in effect until the nomember_alignment pragma is encountered; the reverse is also true.
The optional base_alignment parameter can be used to specify the base-alignment of the structure. Use one of the following keywords for the base_alignment:
The #pragma member_alignment save and #pragma member_alignment restore directives can be used to save the current state of the member_alignment and to restore the previous state, respectively. This feature is necessary for writing header files that require member_alignment or nomember_alignment , or that require inclusion in a member_alignment that is already set.
|

