[antlr-interest] C target with g++ compiler
jimi at temporal-wave.com
Wed Nov 7 15:05:52 PST 2007
Well, if you se the g++ compiler, it is going to try compiling the code as C++, which plainly it isn't ;-). You will find that I did kind of cull most of those things out as Visual Studio 2005 compilers will point out some of this stuff in W4 mode. However, it is best to compile it as C, which is the intent really. You should not need to compile the C runtime as C++ code in order to link with it, you just need to declare your parser interfaces and so on as extern "C". I keep meaning to build that into the C output to make C++ integration easier - sorry I have not done that yet.
> Date: Tue, 6 Nov 2007 21:47:00 -0800> From: dan.hazon at novafora.com> To: antlr-interest at antlr.org> Subject: [antlr-interest] C target with g++ compiler> > 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++.> >
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest