"comma at end of enumerator list" error due to macros in libqof

Jim Paris jim at jtan.com
Mon Jun 6 14:09:55 EDT 2011


Tim M wrote:
> The problem here is that it creates improperly formed code, so the
> question is whether this issue can/should be fixed somehow within the
> qofutil macros, or by simply swapping the comma separators out of
> ENUM_BODY and into the definitions of the typedefs such as the
> LOG_LEVEL_LIST(_) suggestion above, or another solution.  Looking at
> the code some more, I think swapping the commas outright would break
> the other conversion functions.
> 
> Based on your feedback I have the impression that simply eliminating
> DEFINE_ENUM might not be the best approach and I will keep looking for
> a better solution; however, at minimum any enums which are defined
> using DEFINE_ENUM could instead be explicitly defined if they do _not_
> use the other conversion functions.
> 
> I will need to think about the macros some more to see if there is a
> better way to get properly formed code from DEFINE_ENUM, while
> maintaining compatibility with the other conversion functions.

DEFINE_ENUM can just add a dummy element to the end which will follow
the trailing comma:

#define DEFINE_ENUM(name, list)             \
       typedef enum {                       \
           list(ENUM_BODY)                  \
	   __dummy__##name                  \
       } name;

-jim


More information about the gnucash-devel mailing list