[antlr-interest] problems with C target and C++ compiler

Jim Idle jimi at temporal-wave.com
Fri Sep 18 07:55:51 PDT 2009


Download the examples zip form the download page and copy the driver  
code from the examples in the C subdirectories. You are just setting  
up includes incorrectly I think as the compiler thinks your variable  
is an integer.

Jim

On Sep 18, 2009, at 7:06 AM, Stefan Oestreicher <so at deluxe-design.at>  
wrote:

> 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
>
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address


More information about the antlr-interest mailing list