Проблема возникает только при использовании SDK 3.0 с симулятором iphone. Использование SDK 2.0 (с gcc 4.0) скомпилирует. Похоже, это то, что XCode использует по умолчанию.
Очень странно, что эта проблема только для симулятора, а не для самого iphone. Также странно, что gcc4.2 не будет компилироваться с симулятором sdk 2.0 - вы должны использовать gcc4.0.
Для любопытных я написал make-файл, демонстрирующий проблему:
IPHONE_GCC_VER = 4.0
IPHONE_SDK_VER = 3.0
IPHONE_DEV_PATH = /Developer/Platforms/iPhoneOS.platform/Developer
IPHONE_SDK = $(IPHONE_DEV_PATH)/SDKs/iPhoneOS$(IPHONE_SDK_VER).sdk
IPHONE_GCC = $(IPHONE_DEV_PATH)/usr/bin/gcc-$(IPHONE_GCC_VER)
SIMULATOR_GCC_VER = 4.0
SIMULATOR_SDK_VER = 2.0
SIMULATOR_DEV_PATH= /Developer/Platforms/iPhoneSimulator.platform/Developer
SIMULATOR_SDK = $(SIMULATOR_DEV_PATH)/SDKs/iPhoneSimulator$(SIMULATOR_SDK_VER).sdk
SIMULATOR_GCC = $(SIMULATOR_DEV_PATH)/usr/bin/gcc-$(SIMULATOR_GCC_VER)
TEST_FILE=/tmp/test.m
all: info make-test-file
$(IPHONE_GCC) -isysroot $(IPHONE_SDK) -arch armv6 -c $(TEST_FILE)
$(SIMULATOR_GCC) -isysroot $(SIMULATOR_SDK) -arch i386 -c $(TEST_FILE)
info:
@echo "iphone gcc : $(IPHONE_GCC_VER)"
@echo "iphone sdk : $(IPHONE_SDK_VER)"
@echo "simulator gcc: $(SIMULATOR_GCC_VER)"
@echo "simulator sdk: $(SIMULATOR_SDK_VER)"
@echo ""
make-test-file:
echo "#import <Foundation/Foundation.h>" > $(TEST_FILE)
По умолчанию это те, которые работают, но вы можете переопределить их в командной строке. Например:
$ make -f Makefile.iphone-error-demo SIMULATOR_SDK_VER=3.0 SIMULATOR_GCC_VER=4.0
iphone gcc : 4.0
iphone sdk : 3.0
simulator gcc: 4.0
simulator sdk: 3.0
echo "#import <Foundation/Foundation.h>" > /tmp/test.m
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.0 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk -arch armv6 -c /tmp/test.m
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.0 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk -arch i386 -c /tmp/test.m
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/Security.h:29,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLCredential.h:14,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:80,
from /tmp/test.m:1:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:166: error: syntax error before ÔSecPaddingÕ
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:196: error: syntax error before ÔSecPaddingÕ
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:228: error: syntax error before ÔSecPaddingÕ
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecKey.h:257: error: syntax error before ÔSecPaddingÕ
make: *** [all] Error 1
или
$ make -f Makefile.iphone-error-demo SIMULATOR_SDK_VER=2.0 SIMULATOR_GCC_VER=4.2
iphone gcc : 4.0
iphone sdk : 3.0
simulator gcc: 4.2
simulator sdk: 2.0
echo "#import <Foundation/Foundation.h>" > /tmp/test.m
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.0 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk -arch armv6 -c /tmp/test.m
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk -arch i386 -c /tmp/test.m
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:12,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6,
from /tmp/test.m:1:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6,
from /tmp/test.m:1:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/usr/include/float.h:8:24: error: float.h: No such file or directory
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/DriverServices.h:32,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:125,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:21,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:2,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSAppleEventDescriptor.h:8,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:107,
from /tmp/test.m:1:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MachineExceptions.h:29:23: error: xmmintrin.h: No such file or directory
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/DriverServices.h:32,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:125,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:21,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:2,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSAppleEventDescriptor.h:8,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:107,
from /tmp/test.m:1:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MachineExceptions.h:216: error: expected specifier-qualifier-list before Ô__m128Õ
make: *** [all] Error 1