#define in header files in Objective-C

Published on Christian Mayer's Weblog

[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.

Recent Posts

About the Author

Christian is a professional software developer living in Vienna, Austria. He loves coffee and is strongly addicted to music. In his spare time he writes open source software. He is known for developing automatic data processing systems on Debian Linux server.

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

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