help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bison complains about undefined reference of my own data type


From: Laurence Finston
Subject: Re: Bison complains about undefined reference of my own data type
Date: Fri, 28 Nov 2008 12:21:47 +0100 (CET)


On Fri, 28 Nov 2008, sgaurelius wrote:

> Finally, it was somthing really easy and stupid and had nothing to dowith
> bison. I just was worred, because I don't know how much compatible C and C++
> code can be.
 
A linker should be able to link object files no matter what language was 
used to produce them; C, Fortran, C++, Pascal, or whatever.

Normally, valid C code can be compiled by a C++ compiler and the results 
will be more-or-less the same.  That is, one can reasonably expect the 
program to produce the same output given identical inputs.  There are a 
few incompatibilities between C and C++ but they concern rather subtle 
points and you can look this up in Stroustrup, _The C++ Programming 
Language_ or search the internet.  I mix C and C++ all the time and have 
never had to do this.

One thing you might have to look out for is "name-mangling" which C++ 
compilers do.  You might have to turn it off for C code by specifying 
C-linkage, e.g., "extern "C" foo(void);".  I've never had to 
do this for my own code, but I've seen it in other people's.  I would have 
to review when it's necessary;  I don't know off the top of my head.

With respect to Bison, it is absolutely no problem to generate a C parser 
and include C++ code in the actions and link it with C++ code.  This is 
mostly how I use Bison and I've never had any problem with it.

Laurence Finston




reply via email to

[Prev in Thread] Current Thread [Next in Thread]