Is this a valid form of a typedef structure, and if so, what does it mean?

Work with a code fragment right now when form functions are declared:

typedef PACKED(struct) { // some stuff in here } struct_name; 

now ... PACKED is a macro on our part. What does this syntax mean? I do not understand the use of brackets. This is not a compilation, so I assume this is probably not true. Is this close to some other valid syntax, or is it just absurd?

If this is almost acceptable ... how should this code actually be written and what should it mean?

The only form of typedef structure I've seen and can find on the Internet is:

 typedef struct { // some stuff in here } struct_name; 

Solved: all I needed to understand was that struct is a parameter in macro function. Thanks!

+4
source share
3 answers

Usually something in all caches is a macro. In this case, it is likely to decorate the structure declaration with syntax to create a packed structure that will depend on the compiler used.

Most likely, you did not completely specify the definition of the PACKED macro.

+2
source

Most compilers provide functionality to indicate how structures should be stored in memory. It is rarely used, but packed usually means *have this structure occupy the least space possible, even at a loss of speed in accessing its members* .

Given that your code does not compile, I would say that packed most likely has now lost a macro, or a keyword that is not available to the compiler, in the one you are using.

+1
source

With this syntax, PACKED should be a macro.

Perhaps referring to some way to align the structure

  __attribute__(packed, aligned(1)) #pragma pack(push,1) //... #pragma pack(pop) 

although it’s hard for us to tell you, unlike the opposite :))

+1
source

All Articles