Struct in a pack?

Asked

Viewed 33 times

0

What happens when I put an attribute packed in a struct?

What is the difference of struct that has that attribute?

struct test
{
        unsigned char  field1;
        unsigned short field2;
        unsigned long  field3;
} __attribute__((__packed__));
  • https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#Common-Type-Attributes : specifies that each Member [...] of the Structure or Union is placed to minimize the memory required.; I can’t figure out a description of this functionality for the Clang compiler.

  • Usually the identifiers with two underscores are specific to a particular compiler. If you can write your programs without using these features, have more guarantees that these programs are portable,

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.