[antlr-interest] C target with g++ compiler

Dan Hazon dan.hazon at novafora.com
Tue Nov 6 21:47:00 PST 2007


This question is to Jim or users who use the C target.

I'm using the C target.
My code compiles perfectly with gcc but when trying with g++ it fails
with bunch of errors:

/usr/local/include/antlr3bitset.h:51: error: expected unqualified-id
before '||' token
/usr/local/include/antlr3bitset.h:51: error: expected `)' before '||'
token
/usr/local/include/antlr3bitset.h:51: error: abstract declarator
'ANTLR3_BITSET_struct*' used as declaration
/usr/local/include/antlr3bitset.h:51: error: expected ';' before '||'
token

I see that this is because of the following definition in
antlr3bitset.h:

    struct ANTLR3_BITSET_struct  *  (*or)	    (struct
ANTLR3_BITSET_struct  * bitset1, struct ANTLR3_BITSET_struct * bitset2);

g++ seems to be replacing or with ||


And:

vdlParser.c:9085: error: invalid conversion from 'const void*' to
'void*'
vdlParser.c:9205: error: invalid conversion from 'const void*' to
'void*'
vdlParser.c:9481: error: invalid conversion from 'const void*' to
'void*'
vdlParser.c:9626: error: invalid conversion from 'const void*' to
'void*'

This seems to be because of the following definition:

    /** The string name of the exception
     */
    void    *	    name;

    /** The printable message that goes with this exception, in your
preferred
     *  encoding format. ANTLR just uses ASCII by default but you can
ignore these
     *  messages or convert them to another format or whatever of
course. They are
     *  really internal messages that you then decide how to print out
in a form that
     *  the users of your product will understand, as they are unlikely
to know what
     *  to do with "Recognition exception at: [[TOK_GERUND..... " ;-)
     */
    void    *	    message;


In the generated parser code these variables are being assigned antlr
generated constant literal strings (e.g. "Early Exit")
g++ doesn't like this.

Can you suggest an elegant way to overcome those errors?

I'm interfacing with some other C++ code and must use g++.




More information about the antlr-interest mailing list