I have a code as following
ApplicationSetting.h
FOUNDATION_EXPORT BOOL *const TEST_MODE;
ApplicationSetting.m
#ifdef DEBUG
BOOL *const TEST_MODE = YES;
#else
BOOL *const TEST_MODE = NO;
#endif
The above .m file’s code gives me this warning
Incompatible integer to pointer conversion initializing 'BOOL *const'
(aka 'signed char *const') with an expression of type 'signed char';
But, if I change it to be come like this
#ifdef DEBUG
BOOL *const TEST_MODE = NO;
#else
BOOL *const TEST_MODE = YES;
#endif
It works just fine without any warning.
Do you have any idea how could this happens?
You really meant to write a value:
…
BOOLis not an objc object, it is asigned char.as far as the error, the compiler complains because you are assigning numeric values to the pointer value — where only
0(akaNULL) is acceptable to the compiler, and any other number (YESis1) will produce the error/warning.P.S. Just use
bool.