[antlr-interest] using ANTLR and MySQL in C target

Jim Idle jimi at temporal-wave.com
Mon Jul 12 10:36:05 PDT 2010


The MySql headers do a lot of strange things such as #define free - it probably means that you are trying to lump everything together and include all the headers everywhere. Try splitting this out in to a supporting translation unit and just including what you need. For instance, just pass a pointer to the token text and its length and don't including the antlr headers.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Dinesha Balasuriya Weragama
> Sent: Sunday, July 11, 2010 7:23 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] using ANTLR and MySQL in C target
> 
> I am trying to build an ANTLR grammar using the C target.  I want to
> store some data from the grammar into a MySQL database.  However, when
> I include both the mysql and antlr C target runtime libraries in my
> project, I get the following errors.
> 
> gcc -IC:\xampp\xampp\mysql\include -IC:\AntlrC\include -O0 -g3 -Wall -c
> -fmessage-length=0 -osrc\AddParser.o ..\src\AddParser.c
> In file included from C:/AntlrC/include/antlr3.h:33,
>                  from ..\src\AddParser.h:67,
>                  from ..\src\AddParser.c:45:
> C:/AntlrC/include/antlr3defs.h:211: warning: ignoring #pragma warning
> In file included from ..\src\AddParser.c:45:
> ..\src\AddParser.h:99: warning: ignoring #pragma warning
> ..\src\AddParser.h:100: warning: ignoring #pragma warning
> ..\src\AddParser.h:101: warning: ignoring #pragma warning
> ..\src\AddParser.h:102: warning: ignoring #pragma warning
> ..\src\AddParser.h:103: warning: ignoring #pragma warning
> ..\src\AddParser.h:104: warning: ignoring #pragma warning
> ..\src\AddParser.c:205: warning: 'freeScope' defined but not used
> ..\src\AddParser.c:321: warning: 'getTokenNames' defined but not used
> gcc -IC:\xampp\xampp\mysql\include -IC:\AntlrC\include -O0 -g3 -Wall -c
> -fmessage-length=0 -osrc\Test.o ..\src\Test.c
> In file included from C:/xampp/xampp/mysql/include/my_global.h:72,
>                  from ..\src\Test.h:14,
>                  from ..\src\Test.c:8:
> C:/xampp/xampp/mysql/include/config-win.h:203:1: warning: "finite"
> redefined
> C:/xampp/xampp/mysql/include/config-win.h:161:1: warning: this is the
> location of the previous definition
> In file included from ..\src\Test.h:14,
>                  from ..\src\Test.c:8:
> C:/xampp/xampp/mysql/include/my_global.h:605:1: warning:
> "my_reinterpret_cast" redefined
> In file included from C:/xampp/xampp/mysql/include/my_global.h:72,
>                  from ..\src\Test.h:14,
>                  from ..\src\Test.c:8:
> C:/xampp/xampp/mysql/include/config-win.h:307:1: warning: this is the
> location of the previous definition
> In file included from ..\src\Test.h:14,
>                  from ..\src\Test.c:8:
> C:/xampp/xampp/mysql/include/my_global.h:1570: warning: static
> declaration of 'rint' follows non-static declaration
> In file included from C:/AntlrC/include/antlr3.h:33,
>                  from ..\src\AddLexer.h:71,
>                  from ..\src\Test.h:17,
>                  from ..\src\Test.c:8:
> C:/AntlrC/include/antlr3defs.h:211: warning: ignoring #pragma warning
> In file included from C:/AntlrC/include/antlr3tokenstream.h:44,
>                  from C:/AntlrC/include/antlr3baserecognizer.h:42,
>                  from C:/AntlrC/include/antlr3cyclicdfa.h:38,
>                  from C:/AntlrC/include/antlr3.h:40,
>                  from ..\src\AddLexer.h:71,
>                  from ..\src\Test.h:17,
>                  from ..\src\Test.c:8:
> C:/AntlrC/include/antlr3debugeventlistener.h:76: warning: declaration
> does not declare anything
> C:/AntlrC/include/antlr3debugeventlistener.h:76: warning: no semicolon
> at end of struct or union
> C:/AntlrC/include/antlr3debugeventlistener.h:76: error: syntax error
> before numeric constant
> C:/AntlrC/include/antlr3debugeventlistener.h:165: error: 'rewind'
> redeclared as different kind of symbol
> C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:420:
> error: previous declaration of 'rewind' was here
> C:/AntlrC/include/antlr3debugeventlistener.h:165: error: 'rewind'
> redeclared as different kind of symbol
> C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:420:
> error: previous declaration of 'rewind' was here
> C:/AntlrC/include/antlr3debugeventlistener.h:388: error: 'free'
> redeclared as different kind of symbol
> C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdlib.h:366:
> error: previous declaration of 'free' was here
> C:/AntlrC/include/antlr3debugeventlistener.h:388: error: 'free'
> redeclared as different kind of symbol
> C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdlib.h:366:
> error: previous declaration of 'free' was here
> C:/AntlrC/include/antlr3debugeventlistener.h:390: error: syntax error
> before '}' token
> C:/AntlrC/include/antlr3debugeventlistener.h:391: warning: type
> defaults to `int' in declaration of `ANTLR3_DEBUG_EVENT_LISTENER'
> C:/AntlrC/include/antlr3debugeventlistener.h:391: warning: data
> definition has no type or storage class
> In file included from ..\src\Test.h:17,
>                  from ..\src\Test.c:8:
> ..\src\AddLexer.h:103: warning: ignoring #pragma warning
> ..\src\AddLexer.h:104: warning: ignoring #pragma warning
> ..\src\AddLexer.h:105: warning: ignoring #pragma warning
> ..\src\AddLexer.h:106: warning: ignoring #pragma warning
> ..\src\AddLexer.h:107: warning: ignoring #pragma warning
> ..\src\AddLexer.h:108: warning: ignoring #pragma warning
> In file included from ..\src\Test.h:18,
>                  from ..\src\Test.c:8:
> ..\src\AddParser.h:99: warning: ignoring #pragma warning
> ..\src\AddParser.h:100: warning: ignoring #pragma warning
> ..\src\AddParser.h:101: warning: ignoring #pragma warning
> ..\src\AddParser.h:102: warning: ignoring #pragma warning
> ..\src\AddParser.h:103: warning: ignoring #pragma warning
> ..\src\AddParser.h:104: warning: ignoring #pragma warning
> 
> I have used the MySQL library and the ANTLR C runtime library
> separately with the relevant sections of the same program and have no
> trouble then.  Please let me know if anyone has used these two
> libraries together and if so, how you can overcome the above
> redeclaration errors.
> 
> Thank you
> 
> 
> 
> 
> 
> 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