On Mon, 2 Dec 2002, Anton Altaparmakov wrote:
> On 2 Dec 2002, Richard Russon wrote:
> > We also seem to be relying on the size of __packed__ enums. It's a
> > nice feature, but it's another gcc extension. In our code we can:
>
> I _don't_ care. I don't want pragmas everywhere! gcc doesn't understand
> pragmas anyway so the only way to be compatible with MSVC would be to do
> some disgusting things like:
>
> #ifdef MSVC
> #define __PACKED__ <insert correct pragma crap here>
> #define __UNPACKED__ <insert correct pragme crap here>
> #define __attrbiute__ <what do we put here so it disappears?!?>
> #define __packed__ <what do we put here so it disappears?!?>
> #else
> #define __PACKED__ <what do we put here so it disappears?!?>
> #define __UNPACKED__ <what do we put here so it disappears?!?>
> #endif
>
> And then we rewrite:
>
> > typedef enum {
> > ABC = 4,
> > } RICH __attribute__ ((__packed__));
>
> to:
>
> __PACKED__
> typedef enum {
> ABC = 4,
> } RICH __attriute__ ((packed__));
> __UNPACKED__
Having thought about this some more, it is not that bad. But we should
take it a bit further to make it cleaner.
Let's have a PACKED_TYPEDEF define as well as a PACKED_TYPEDEF_END (or
something to that effect, feel free to use a better name...).
So the header files would then become:
PACKED_TYPEDEF enum {
blah = 4,
} myenumname PACKED_TYPEDEF_END;
or
PACKED_TYPEDEF struct {
blah = 4,
} mystructname PACKED_TYPEDEF_END;
And then have the compat.h header file (or whatever the name was) deal
with defining PACKED_TYPEDEF{,_END} depending on compiler/OS or whatever
you like. That makes it even nicer than the __attribute__ strangeness and
the pragma strangeness that gcc and msvc have respectively.
So basically feel free and do something along those lines if you wish...
Cheers,
Anton
--
Anton Altaparmakov <aia21 at cantab.net> (replace at with @)
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
|