BYTE alignment in Linux

BYTE alignment in Linux

Post by Barbara Tsogl » Tue, 28 Jan 2003 11:44:14


I  would like your advise in the following matter:

I am working with Linux and I tryed to use "pragma pack" command but with no
Is there something equivalent to "pragma pack" command as it is used in
Visual Studio that can be used in Linux gcc compiler?

#pragma pack (push ,1)
#pragma pack (pop)

What I want to achieve is 1 byte alignment for the members of a C structure.
Is there another way for doing this?

Thank you in advance for your time!



1. struct byte alignment on Linux

I have this structure with size: 71 bytes. but sizeof(struct
variable_list) gives its size as 73. I am aware that this is related
to byte alignement of structure. But I am using GNU __attribute__ to
align it on one bye boundary.

// up to 71 bytes, variable length
struct variable_list {
    u_char name_length;     // number of subid's in name
   u_char val_len;         // The value length
   u_char type;            // ASN type of variable
   oid name[MAX_NAME_LEN]; // Object identifier of variable
   union { /* value of variable */
      unsigned char string[MAX_STRINGVAL_LEN];
      short integer;
      u_long linteger;
   } val;

I have even tried to build this with flags '-fpack-struct' or
'-mstructure-size-boundary=1' but both these options give size as 76.

I want this size to be = 71... Windows gives its size as 71... how to
make it same on Linux?

Any Suggestions? Thanks in advance,
Rohit Malaviya

2. modem used by other process ??

3. Byte alignment in C++ on Linux

4. Oh no!Sendmail, user unknown?

5. Byte alignment in Linux

6. how to stop screen blanking after 5 min?

7. question:how to compile a program with 1 byte alignment setting

8. make zImage

9. Byte Alignment

10. Single Byte Alignment

11. Byte alignment of structures in Unix "C"

12. two byte

13. Byte alignment.