On Saturday, 28 March 2015 at 07:23:12 pm +0100, Élie Roux wrote:
> Le 28/03/2015 19:09, Jakub Jelinek a écrit :
> > On Sat, Mar 28, 2015 at 12:36:31PM -0400, Henry So Jr. wrote:
> >> I would like to change the #defines for ST_, TR_, NLBA_, etc. into
> >> enums. This would make debugging easier. However, I have two concerns.
> >>
> >> Firstly, it changes the size of the structures (= more memory to compile
> >> a score) unless I use the GCC __attribute__(packed) extension. Are we
> >> targetting anything other than GCC? If so, does anyone know of a more
> >> portable way of making enums smaller, or does that mean we switch to C++
> >> to give enums a specific underlying type?
> >
> > Both C++ standard and GNU C extensions support enum bitfields, and you could
> > use them conditionally.
> > E.g. if using GCC (or other compiler that supports this), you would use enum
> > bitfields, otherwise either use full enums and increase size, or use ints
> > instead.
> > GCC in itself used to use (before it switched to C++ which always supports
> > this):
> > #if defined(__GNUC__) && __GNUC__ >= 2
> > #define ENUM_BITFIELD(TYPE) __extension__ enum TYPE
> > #else
> > #define ENUM_BITFIELD(TYPE) unsigned int
> > #endif
> > which is then used as:
> > enum foobar { ..., F1, F2, F3, ... };
> >
> > struct bar {
> > ...
> > ENUM_BITFIELD (foobar) : 7;
> > ...
> > };
> > (that is the second option). For supporting either enum bitfields, or
> > full sized enums, you would need some macro that has the bitfield width
> > as one of the arguments, and would expand either to that
> > __extension__ enum TYPE : WIDTH
> > or
> > enum TYPE
>
> That would be good... Clang apparently supports the __attribute__
> (packed), but the condition would be useful for people wanting to
> compile Gregorio on weird Windows compilers (Microsoft compilers, Open
> Watcom, etc.).
Is there a better condition that lets more compilers support an enum in
the structure?
In any case, thanks for pointing this out.
>
> > Note ISO C99 or C11 has inline support too
>
> Good! Gregorio uses C99 so it shouln't be a problem.
Thanks for pointing this out too.
>
> Thank you,
> --
> Elie
>
I'd like to get release-3.0 merged into develop and then branch that in
my own repository can I can start on these changes.
Regards,
Henry
_______________________________________________
Gregorio-devel mailing list
[email protected]
https://mail.gna.org/listinfo/gregorio-devel