[antlr-interest] Macro redefinition warnings from libantlr3c headers

Christopher L Conway cconway at cs.nyu.edu
Thu Mar 4 10:42:30 PST 2010


I'm getting a lot of compiler warnings like the following when I
compile against libantlr3c:

In file included from
/home/chris/Tools/builds/libantlr3c/include/antlr3defs.h:217,
                 from /home/chris/Tools/builds/libantlr3c/include/antlr3.h:33,
...
/home/chris/Tools/builds/libantlr3c/include/antlr3config.h:92:1:
warning: "PACKAGE" redefined

and so on for PACKAGE_BUGREPORT, PACKAGE_NAME, etc.

Apparently, this is due to Automake-generated symbols being exported
in the public header files (we use Automake too, so we have the same
symbols in our project). There's some information about errors like
these in this StackOverflow question:
    http://stackoverflow.com/questions/7398/how-to-avoid-redefining-version-package-etc

I'm not sure what the best fix for this is. There are at least two options:

1. Rename antlr3config.h to config.h. I believe this will cause the
#include in antlr3defs.h to pick up my project's config.h, which may
or may not be a problem. I can confirm that this change makes the
compiler warnings disappear.

2. Make sure antlr3config.h in only #include'd from .c files, maybe by
breaking antlr3defs.h into a public and private portion.

This is a minor thing, but it's apt to make my colleagues grouchy
about adopting ANTLR3 (they like a clean build ;-)...

Regards,
Chris


More information about the antlr-interest mailing list