Snowman
Snowman

Reputation: 32091

Why does Apple use a special COREDATA_EXTERN qualifier instead of just extern?

Sometimes I like to browse Apple source code to see how the pros do it, and sometimes learn a thing or two. I'm looking now at the header file for NSManagedObjectContext.h, and for their global variables, for say NSManagedObjectContextDidSaveNotification, they declare it like so:

COREDATA_EXTERN NSString * const NSManagedObjectContextDidSaveNotification;

whereas typically it would just be:

extern NSString * const NSManagedObjectContextDidSaveNotification

Cmd+clicking on COREDATA_EXTERN takes me to its definition:

#define COREDATA_EXTERN     extern

So COREDATA_EXTERN is just equal to extern, so my question is, why do they not just use extern?

Upvotes: 4

Views: 121

Answers (1)

MikeG
MikeG

Reputation: 4035

If you check out the CoreDataDefines.h file, you'll see a few different definitions for COREDATA_EXTERN, such as:

#ifdef __cplusplus
#define COREDATA_EXTERN     extern "C"

or:

#ifdef __cplusplus
#define COREDATA_EXTERN     extern "C" _NSWINDOWS_DLL_GOOP

This allows for some platform specific definitions, all contained under a single definition.

Windows goop, that's funny. What I'd like to know is when you would be compiling core data on a Windows platform....

Upvotes: 3

Related Questions