> On Mar 7, 2017, at 8:45 AM, bigpig <[email protected]> wrote:
> 
> if there is C++ compiler and use C linkage,but if there isn’t C++ compiler 
> then use what?

Then it’s a C compiler, which obviously uses C linkage.

> And what is the reason of using this way in code?

To make sure that the functions declared inside can be called from C or C++ 
code.

If this “extern” declaration weren’t there, a C++ compiler would treat those 
functions as having C++ linkage, which means their names will be “mangled” to 
include information about their parameter types. That would cause a link error, 
because the program is referring to the function by a mangled name while the 
actual function has a plain C name.

—Jens
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to