[antlr-interest] [C Runtime] Redefinition issue in antlr3convertutf.h
jimi at temporal-wave.com
Mon Nov 21 09:28:52 PST 2011
It is more likely that you need to reorder your includes as some other
non-antlr header has defined true and false.
It is not likely that those interfering headers have used the same types
and so on, even though it is likely that they end up being the same values
in the end (assuming you are not trying to compile the runtime as C++).
But if I just use whatever you give me, it could generate strange errors
that are harder to resolve. Also, if I undef them in the header, I can't
predict what I have done to your other code. Hence, it is better to leave
it; though I think that there is an argument not to use such obvious names
in the library code (but I reused the standard Unicode.org supplied code).
If you read through the API docs, you will see that there are various
@directives that you can use to influence the order of includes. You can
also look at the examples, which talk about this and how to relocate code
outside the space so you don't get these interferences.
Finally, this possibly indicates a more fundamental issue if you are
trying to embed code that refers to things outside ANTLR, within grammar
actions. Ideally you just call external helper methods that know how to
talk to your other components. If however you are just including antlr.h
in files outside the grammar, then you should just include antlr first, or
undef the definitions after including the other headers, assuming that you
do not use them after that.
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Gonzague Reydet
> Sent: Sunday, November 20, 2011 11:29 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] [C Runtime] Redefinition issue in
> Hi all,
> Using the ANLTR C runtime v3.4, I encounter a redefinition error of
> and "true" values in antlr3convertutf.h at compile time when including
> the antlr3.h file in my code.
> IMO we should have a verification to check if those flags are already
> defined or not before defining them in the antlr3convertutf.h file.
> Something like the following code should fix my compiling issue :
> #ifndef true
> #define true ANTLR3_TRUE
> #ifndef false
> #define false ANTLR3_FALSE
> Is there any reason for not doing this check here? Is this a known
> Moreover I not sure this is the right place to define such generic
> Why do you need to define them here?
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
More information about the antlr-interest