In a Cocoa application, I would like to use conditional compilation, for example:
#if MACOSX_DEPLOYMENT_TARGET <= MAC_OS_X_VERSION_10_4 [[NSFileManager defaultManager] removeFileAtPath:path handler:nil]; #else [[NSFileManager defaultManager] removeItemAtPath:path error:NULL]; #endif
My hope is that this will prevent the compiler from warning about removeFileAtPath: it is deprecated when MACOSX_DEPLOYMENT_TARGET = 10.6, since it should not compile this line.
This does not work.
When MACOSX_DEPLOYMENT_TARGET = 10.6, I get a warning that removeFileAtPath: is deprecated. But he should not compile this line, therefore he should not warn about obsolete methods!
(I set MACOSX_DEPLOYMENT_TARGET both in the project build settings and in the target build settings. I have BASE_SDK set to 10.6 and also indicates GCC 4.2 in both.)
What am I doing wrong? Do I have any fundamental misunderstanding of conditional compilation?
xcode cocoa conditional-compilation macos
user532477
source share