[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C parser Can't be Linked to C++ Driver
From: |
Philip Herron |
Subject: |
Re: C parser Can't be Linked to C++ Driver |
Date: |
Tue, 08 Sep 2009 01:04:38 +0100 |
User-agent: |
Thunderbird 2.0.0.23 (X11/20090817) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Evan Carew wrote:
> I'm trying something not found in any of the manuals or the
> O'Reilly books. I'm trying to create a C lexer and parser (mainly
> because C++ isn't really supported all that well yet), then link
> them in with my C++ driver routine. My problem is that I am having
> trouble getting my linker to recognize the yyparse() function found
> in my parser.tab.c file. This is rather embarrassing as it
> shouldn't be a problem. I can see the stupid symbol in the nm
> listing for the parser object file, but I can't seem to get g++ to
> accept it. <sigh>.
>
> If anyone has gotten past this issue, I'd appreciate a pointer so I
> can get past my senior moment.
>
> Thanks, Evan
Hey Evan
Hmm this sounds interesting, sometimes mixing C and C++ you need to do
stuff like:
#ifdef __cplusplus
extern "C" {
#endif
.....
#ifdef __cplusplus
}
#endif
But you would use that if you have C++ code you want to call from C,
http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html
But are you using yacc -d? And including the generated header file? I
cant remember what they are called by default any more been using
automakes ylwrap for too long :)
But yyparse isn't declared in that prototype in my lexer what i do is:
int parse( FILE* fin )
{
yyin= fin;
prompt();
int err= yyparse();
return err;
}
fin could be stdin or a fopen'd file :) But in the top of the lexer i
declare the prototype yyparse() and it works.
%{
.......
#include "libparser_la-parser.h"
#include "crules.h"
#include "symbols.h"
extern int yyparse( );
%}
Not sure if any of that helps :)
- --Phil
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkqln5MACgkQAhcOgIaQQ2HgeQCglVd7mRWaKSGUnixG+uVSwfIF
4MsAn3gOr1nWb53vpsjaGvlyiZ+QXjzD
=OAvI
-----END PGP SIGNATURE-----