[antlr-interest] problems with C target and C++ compiler
Stefan Oestreicher
so at deluxe-design.at
Fri Sep 18 07:06:40 PDT 2009
Hi,
I recently started playing around with antlr and first of all I have to
say that it's a really awesome tool. Great work, thanks!
Now that I got a small and simple working grammar I'd like to write a
small C++ (I need to use LLVM eventually) program that processes an
input file and just dumps the AST to stdout, so I looked into the C
examples but unfortunately I ran into a compiler problem, probably due
to my limited experience with C/C++.
The compiler complains that ISO C++ forbids integer/pointer comparison
at the NULL pointer check:
fileName = (pANTLR3_UINT8)argv[1];
input = antlr3AsciiFileStreamNew(fileName);
if (input == NULL) { // forbidden integer/pointer comparison - huh?
printf("Failed to open %s", fileName);
return -1;
}
If I compile as C it issues more or less the same message but then it's
only a warning. However when I run the program it segfaults in the lexer
factory (MyGrammarLexerNew). This also happens when I just remove the
null pointer check when compiling as C++, however input is most
certainly not null.
I'm compiling on windows xp using the mingw toolchain (gcc 3.4.5) but I
verified that the same problem exists on debian etch with gcc 4.1.2. My
ANTLR and runtime version is 3.1.3.
I'd appreciate any help as I couldn't find any hint on what I'm doing
wrong.
thanks,
Stefan
More information about the antlr-interest
mailing list