[antlr-interest] [C target] mutiple inclusion of headerfiles generated by the parser fails

George J. Shannon George.Shannon at raphaelanalytics.com
Wed Jun 11 15:07:55 PDT 2008


Jim: 

 

FYI - I've had a similar experience in that both versions compile fine.

 

Is there a particular requirement for setting up MSVC 2005 to work with the
library?  I've had success when using the library within another library but
not an executable.

 

I created a dll library for my parser using VS 2005 and compiled the
C-generated files (xyzLexer.c and xyzParser.c) as C++ with no compiler
errors or warnings.  There were no compiler errors or warnings per Florent's
note in either case (having the pragmas in the correct or reverse order made
no difference).

 

I consume the parser dll in our main C++ project executable; both are native
C++.

 

However, I have been receiving the following errors for antlr3lexer.h line
101 when using ANTLR functions from the main executable project:

 

error C2059: syntax error : '<L_TYPE_raw>'     c:\Documents and
Settings\RAI\My Documents\Visual Studio
2005\Projects\ControlDiagnosticsToolkit\ControlsLanguageParser\antlr\include
\antlr3lexer.h       101       

 

error C2238: unexpected token(s) preceding ';'      c:\Documents and
Settings\RAI\My Documents\Visual Studio
2005\Projects\ControlDiagnosticsToolkit\ControlsLanguageParser\antlr\include
\antlr3lexer.h       101       

 

To see if there is something related to project templates for a library
versus an executable in MSVS, I stripped out all code in the main executable
program that makes use of the ANTLR C libraries and moved this to my parser
dll.  Both projects now compile OK with no warnings.

 

I also verified that both projects have identical properties with one
exception - the parser dll project inherited _WINDLL preprocessor definition
since it is a lib project.

 

I don't know if this is related but thought I would pass it along if it is
helpful in some way, or maybe a cure for insomnia.

 

Regards,

 

George Shannon

President, Raphael Analytics, Inc.

16 Spur Drive

Fenton, MO 63026

(314) 550-5589 (cell)

 <mailto:George.Shannon at raphaelanalytics.com>
George.Shannon at raphaelanalytics.com

 <http://www.raphaelanalytics.com> www.raphaelanalytics.com

 

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited.   If you received
this in error, please contact the sender and delete the material from any
computer.

  _____  

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Jim Idle
Sent: Wednesday, June 11, 2008 3:40 PM
To: florent.teichteil at gmail.com
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] [C target] mutiple inclusion of headerfiles
generated by the parser fails

 

On Wed, 2008-06-11 at 16:23 -0400, Florent Teichteil wrote: 

 
Multiple inclusion of header files generated by the parser creates
compilation errors due to an inversion in the order of #endif pragmas.
 
At the end of 'langLexer.h' and 'langParser.h', the following lines:
 
 
#endif
 
#ifdef __cplusplus
}
#endif
 
/* END - Note:Keep extra line feed to satisfy UNIX systems */
 
 
should be replaced by:
 
 
#ifdef __cplusplus
}
#endif
 
#endif
 
/* END - Note:Keep extra line feed to satisfy UNIX systems */
 
 
Otherwise, the C++ compiler complains with the bracket '}'. The error
is obvious because the #ifdef pragmas are defined in the inverse oder
at the beginning of these two files.


Cheers, i wil lfix that, though I am not sure why my own C+++ test is
working :-)

Jim 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080611/0b3c76be/attachment.html 


More information about the antlr-interest mailing list