[antlr-interest] c runtime with templates

Carter Cheng carter_cheng at yahoo.com
Fri Feb 13 09:01:38 PST 2009


Thanks for the reply.

I did actually manage to find a semi workaround for this though it is a bit cumbersome (involves manually editing the extern "C" scopes in the tree grammar .h generated file). I am a bit of a C++ newbie and part of me is curious if this extern "C" stuff is really needed here since I am compiling everything with g++.

Unfortunately given how the declarations look in the header it seems that since in certain cases I am returning stl types these show up in some of the generated structs in the header i suspect that #ifdefing them out of the header would mean the header would not compile.


--- On Fri, 2/13/09, Robert Soule <robert.soule at gmail.com> wrote:

> From: Robert Soule <robert.soule at gmail.com>
> Subject: Re: [antlr-interest] c runtime with templates
> To: carter_cheng at yahoo.com
> Cc: antlr-interest at antlr.org
> Date: Friday, February 13, 2009, 6:36 AM
> Try adding this to your grammar:
> 
> @header {
> #ifndef _YourFile_H
>   #include <your_includes>
>   using namespace std;
> #endif
> }
> 
> where you replace YourFile and your_includes appropriately.
> I think that you want to be able to include your stl
> related stuff
> in your .c file, but not in your header file, and the above
> should
> work.
> 
> -Robert
> 
> On Fri, Feb 13, 2009 at 3:52 AM, Carter Cheng
> <carter_cheng at yahoo.com> wrote:
> >
> > Hi,
> >
> > I have been playing around with intermingling the C
> runtime with some C++ STL constructs (admittedly not
> exception safe) and noticed I that I get what I believe are
> linker errors doing to interactions between the extern
> "C" { ... } declaration which shows up in the
> header file and stl includes such as #include <list>
> etc.
> >
> > Is there a way workaround this issue (ignoring for the
> moment the issue of STL containers throwing exceptions in C
> code which are uncaught).
> >
> > Thanks in advance,
> >
> > Carter
> >
> >
> >
> >
> > 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