Re: Preventing name mangling of exported symbols in a c++ file
Re: Preventing name mangling of exported symbols in a c++ file
- Subject: Re: Preventing name mangling of exported symbols in a c++ file
- From: Eric Albert <email@hidden>
- Date: Tue, 3 Jan 2006 10:48:16 -0800
On Jan 3, 2006, at 8:36 AM, Matt Gough wrote:
In CodeWarrior, my .h and .cp files are akin to this:
PublicStuff.h
#ifdef __cplusplus
extern "C" {
#endif
void SomeFunction(const UInt32 value);
#ifdef __cplusplus
}
#endif
end of PublicStuff.h
PublicStuff.cp
#pragma export on
void SomeFunction(const UInt32 value)
{
// real code goes here
}
#pragma export off
End of PublicStuff.cp
In CodeWarrior, the function names do not get mangled, but in XCode
they appear to be.
As Xcode does not support #pragma export, I am using an Exported
Symbols File. However at link time, it tells me that it
ld: symbols names listed in -exported_symbols_list:
Exported_Symbols.txt not in linked objects
Doing a disassembly of PublicStuff.cp shows that all my names have
indeed been mangled.
You'll want to define each of your functions in PublicStuff.cp as
extern "C", like this:
extern "C" void SomeFunction(const UInt32 value) {
// real code goes here
}
I often see people do something like this in a prefix file:
#ifdef __cplusplus
#define EXPORT extern "C"
#else
#define EXPORT
#endif
and then write their function definitions like this:
EXPORT void SomeFunction(const UInt32 value) {
// real code goes here
}
Hope this helps,
Eric
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden