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: Samuel Tardieu
Subject: Re: Bison complains about undefined reference of my own data type
Date: Fri, 28 Nov 2008 14:47:53 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

>>>>> "Laurence" == Laurence Finston <address@hidden> writes:

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

You need to do it to interface to any library written in C (such as
the standard C library for example). For example, try the following
C++ code with and without 'extern "C"'. Without it, you won't be able
to link. Fortunately, all your system headers already provide you with
'extern "C"' by default.

extern "C" void exit(int);
int main()
{
  exit(0);
}





reply via email to

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