[parted-devel] Style of __attribute__ ((packed)) and typedef?

Debarshi Ray debarshi.ray at gmail.com
Wed Feb 14 20:46:45 CET 2007


What is the style to be followed while using __attribute__ ((packed))
and typedef with structures? I find both the following two variants in
the code:

a. struct __attribute__ ((packed)) _foo {
    ...
    };
    typedef struct _foo foo;

b. typedef struct foo {
    ...
    } __attribute__ ((packed)) foo_t;

Which is the preferred way to do this?

I personally prefer the first one because:
(i) typedef struct _foo foo; has been followed for most of the major
structures like PedDisk, PedPartition, etc..
(ii) Having the __attribute__ in the first line is more readable since
the information is available immediately. One does not have to scroll
down to see it.

What are your views?

Happy hacking,
Debarshi
-- 
After the game the king and the pawn go into the same box.
                -- Italian proverb



More information about the parted-devel mailing list