[prog] GNU autotools and namespaced libraries
John Clarke
johnc+linuxchix at kirriwa.net
Thu Dec 16 15:04:27 EST 2004
On Wed, Dec 15, 2004 at 09:32:00 -0600, Meredith L. Patterson wrote:
> unpacking what you mean by "functions which have a C linkage", though;
> would you mind elaborating?
Anything enclosed in 'extern "C" { ... }' has a C linkage, i.e. it's
pure C code. The compiler doesn't do the C++ name mangling on anything
in these blocks, the same as if that part of the code was compiled with
a C compiler.
Here's an example:
[johnc at dropbear ~/tmp]$ cat test.C
char func1()
{
return 'a';
}
extern "C"
{
char func2()
{
return 'a';
}
}
[johnc at dropbear ~/tmp]$ gcc -c test.C
[johnc at dropbear ~/tmp]$ nm test.o | grep func
00000000 T func1__Fv
00000008 T func2
See what the compiler has done to func1's name in the object file?
That's name mangling, and it's why AC_CHECK_LIB fails. func2 though,
being C, is unchanged, and AC_CHECK_LIB will be able to find it.
Does this help?
Cheers,
John
--
I also had to use Visual Source Safe at one job, but that was a trauma I
hope never to repeat. It would have been better for source code
control to post our source code to comp.sources.unix and retrieve the
versions using groups.google.com. -- Paul Tomblin
More information about the Programming
mailing list