help-bison
[Top][All Lists]
Advanced

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

Re: problem linking program containing bison-generated parser


From: Alfonso Urdaneta
Subject: Re: problem linking program containing bison-generated parser
Date: Sun, 13 Mar 2005 09:28:51 -0500
User-agent: Mozilla Thunderbird 1.0 (Macintosh/20041206)

Volker Wegert wrote:
Alfonso Urdaneta <address@hidden> writes:

Works without problems, now :-)

Do you know why, or don't really care once it works ?


I don't know why, and yes, I'd like to know. :-)

Thanks in advance
  Volker


C++ allows you to create functions with the same name and different arguments. To keep them straight, the functions are internally represented as a glob of the function name the args, the phase of the moon, and your shoe size. This is called "name mangling".

C does not.

When you call a C function from a C++ program, the compiler does not know that its a C function, so if you call foo, at link time it actually looks in the symbol table for a function called foo_no_args_and_the_author_likes_cheese(). Since there is of course no function like that, because foo is a c function, you will get link errors.

By putting the "extern C" bit, you are telling the compiler to not mangle the name before it tries to find it in the symbol table and your linker errors go away.



--
alfonso e. urdaneta
www.red82.com - are you ready ?




reply via email to

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