Christian Mayer's Weblog

#define in header files in Objective-C

[This post was originally posted as a Stackoverflow question.]

I have a Global.h that looks like

#define NUMBERX 21

In AppDelegate.h I include the Global.h file. In the AppDelegate.m I include the AppDelegate.h file. But in the AppDelegate.m I can’t access the NUMBERX variable.

ERROR: Use of undeclared indentifier 'NUMBERX'.

If I define NUMBERX in AppDelegate.h then it works, but I want include only the header file (Global.h) in all other header files where I want to use the NUMBERX variable.

How can I solve that?

Update, 2011-07-05 16:12: Solution

If you’re using Objective-C standard #import to include your header file, try replacing it with a C #include.

Posted on .
Categories: Programming, Productivity
Tags: Apple, Objc, Objective-C, Objective, C, Standard, Header

Categories | RSS Feed | Usage | Imprint
Copyright © 2006 by