[antlr-interest] [C target] #define clashes: would it be possible to add ANTLR_ prefix to automatically generated macros?

Dinghao Wu dinghao at microsoft.com
Fri Aug 1 16:05:26 PDT 2008


It is similar for ANTLR generated code for grammar rules. Once I had rules called "null" and "string". The generated C# code clashes. I think the generated code should add some prefix so that it won't generate a method called null() or string().

Dinghao

-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Florent Teichteil
Sent: Friday, August 01, 2008 3:26 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] [C target] #define clashes: would it be possible to add ANTLR_ prefix to automatically generated macros?

Hi,

I have been using ANTLR C target with success for several months...
until I included a file from the BOOST C++ library set.

One of my ANTLR rule is DOMAIN.
ANTLR lexer (C target) automatically generates the macro "#define DOMAIN 4".
I include a BOOST header file (for hashtable support) after the lexer
header file. Then, I am not able to parse the DOMAIN rule because
BOOST redefines it to 1!

I think BOOST should prefix its macros, but it would be safer if ANTLR
added some prefix to macros it generates in header files.

What do you think about it?

Best,
Florent Teichteil



More information about the antlr-interest mailing list