[antlr-interest] Couple of issues with C target's runtime code

Stuart Dootson stuart.dootson at gmail.com
Fri Jun 8 12:02:46 PDT 2007


Jim - I used the C target for the first time today - nice job! Looking
at the code, I'm glad I use C++ to do OO ;-)

Anyway - couple of issues (guess I ought to mention I'm using the
version of the runtime that comes with the release of Antlr 3.0 - if
there's a later version of the runtime I ought to be using, please let
me know!!!) -

1. You use the presence of the macro 'WIN32' to determine that you're
compiling for Windows 32. However, you might be better using '_WIN32'
(see http://msdn2.microsoft.com/en-us/library/b0084kay(VS.80).aspx).
'WIN32' is added to the command line by Visual Studio 2005, whereas
'_WIN32' is *always* defined. I compiled my first sample grammar at
the command line (what can I say - I'm an old-fashioned sort of a
developer), and it complained about not finding 'antlr3config.h', as
it was following the Unix path.

2. The release mode static library for Windows is compiled using the
'_fastcall' calling convention (when using the Visual Studio 2005
project). Is this for a reaason other than performance? Anyway - the
header file doesn't mark the functions exported from the library as
'_fastcall', which means that the application won't link using the
default compiler options. Could I suggest either a) changing the
library to use '_cdecl' (I don't think the performance impact will be
significant), or b) marking the exports as '_fastcall' in the header
file. Either option will work better with the default compiler
settings. I guess b) is the optimal choice?

Apart from that, I found your runtime very easy to get up and running
- took about half an hour, including building the runtime and
deciphering the runtime source to determine what sequence of calls to
tie file stream, lexer, token stream and parser together.

Stuart Dootson


More information about the antlr-interest mailing list