Vyacheslav Vyacheslav - 10 days ago 6
Objective-C Question

if else define for preprocessor

//initial code:

#define MYDEBUG YES

#if (defined(MYDEBUG) && MYDEBUG == YES)
#define NATIVEUNITID @"unitid_debug"
#else
#define NATIVEUNITID @"unitid_release"
#endif


//somewhere inside the code


NATIVEUNITID
is
@"unitid_release"


May be I do not understand something. But why? What is the proper way to define
NATIVEUNITID
using the other define?

I've tried both
#if (MYDEBUG)
and
#if (MYDEBUG == true)
but I obtain the same result.

Please, help me to understand this simple case. How can I receive
NATIVEUNITID
is
@"unitid_debug"
?

Answer

The preprocessor cannot evaluate == for "strings".

You could retain your notation if you write #DEFINE YES 1

Comments