• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Preventing name mangling of exported symbols in a c++ file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Preventing name mangling of exported symbols in a c++ file
      • From: Steve Checkoway <email@hidden>
References: 
 >Preventing name mangling of exported symbols in a c++ file (From: Matt Gough <email@hidden>)

  • Prev by Date: Re: Linker warning message
  • Next by Date: Re: iCode development tool
  • Previous by thread: Preventing name mangling of exported symbols in a c++ file
  • Next by thread: Re: Preventing name mangling of exported symbols in a c++ file
  • Index(es):
    • Date
    • Thread