Hi, I'd like to use C++11 features but I can't find a way to compile Cocos2d x-code projects (the template ones).
I first generate the template project and then change the C++ dialect to either C++11 or gnu-C++11.
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:110:69: error: constant expression evaluates to -1 which cannot be narrowed to type 'unsigned int' [-Wc++11-narrowing]
{ kPVRTextureFlagTypePVRTC_2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1, 2, true, kCCTexture2DPixelFormat_PVRTC2 },
^~
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:110:69: note: override this message by inserting an explicit cast
{ kPVRTextureFlagTypePVRTC_2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1, 2, true, kCCTexture2DPixelFormat_PVRTC2 },
^~
st)tic_cast<unsigned int>(
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:110:73: error: constant expression evaluates to -1 which cannot be narrowed to type 'unsigned int' [-Wc++11-narrowing]
{ kPVRTextureFlagTypePVRTC_2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1, 2, true, kCCTexture2DPixelFormat_PVRTC2 },
^~
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:110:73: note: override this message by inserting an explicit cast
{ kPVRTextureFlagTypePVRTC_2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1, 2, true, kCCTexture2DPixelFormat_PVRTC2 },
^~
st)tic_cast<unsigned int>(
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:111:69: error: constant expression evaluates to -1 which cannot be narrowed to type 'unsigned int' [-Wc++11-narrowing]
{ kPVRTextureFlagTypePVRTC_4, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1, 4, true, kCCTexture2DPixelFormat_PVRTC4 },
^~
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:111:69: note: override this message by inserting an explicit cast
{ kPVRTextureFlagTypePVRTC_4, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1, 4, true, kCCTexture2DPixelFormat_PVRTC4 },
^~
st)tic_cast<unsigned int>(
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:111:73: error: constant expression evaluates to -1 which cannot be narrowed to type 'unsigned int' [-Wc++11-narrowing]
{ kPVRTextureFlagTypePVRTC_4, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1, 4, true, kCCTexture2DPixelFormat_PVRTC4 },
^~
/Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/textures/CCTexturePVR.cpp:111:73: note: override this message by inserting an explicit cast
{ kPVRTextureFlagTypePVRTC_4, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1, 4, true, kCCTexture2DPixelFormat_PVRTC4 },
^~
st)tic_cast<unsigned int>(
4 errors generated.
This is easy to fix by adding static casts.
Once done, everything compile and run.
Now if I also set the library to LLVM libc++ (that support C++11), I get this compiler error:
CompileC /Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/test_cocos2d_chipmunk.build/Debug-iphonesimulator/test_cocos2d_chipmunk.build/Objects-normal/i386/CCScheduler.o test_cocos2d_chipmunk/libs/cocos2dx/CCScheduler.cpp normal i386 c++ com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk
setenv LANG en_US.US-ASCII
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch i386 -fmessage-length=0 -std=c++11 -stdlib=libc++ -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wformat -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-sign-compare -Wno-shorten-64-to-32 -Wno-newline-eof -Wc++11-extensions -DDEBUG=1 -DCOCOS2D_DEBUG=1 -DUSE_FILE32API -DTARGET_OS_IPHONE -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -fexceptions -fasm-blocks -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version-min=10.6 -g -fvisibility-inlines-hidden -Wno-conversion -Wno-sign-conversion -D__IPHONE_OS_VERSION_MIN_REQUIRED=50100 -I/Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/test_cocos2d_chipmunk.build/Debug-iphonesimulator/test_cocos2d_chipmunk.build/test_cocos2d_chipmunk.hmap -Itest_cocos2d_chipmunk/libs/Chipmunk/include/chipmunk -I/Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Products/Debug-iphonesimulator/include -Itest_cocos2d_chipmunk/libs/cocos2dx -Itest_cocos2d_chipmunk/libs/CocosDenshion/include -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/usr/include/libxml2 -I/Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/test_cocos2d_chipmunk.build/Debug-iphonesimulator/test_cocos2d_chipmunk.build/DerivedSources/i386 -I/Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/test_cocos2d_chipmunk.build/Debug-iphonesimulator/test_cocos2d_chipmunk.build/DerivedSources -F/Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Products/Debug-iphonesimulator -include /Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/PrecompiledHeaders/Prefix-flctrunwlowyjndlnuagbuekehow/Prefix.pch -MMD -MT dependencies -MF /Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/test_cocos2d_chipmunk.build/Debug-iphonesimulator/test_cocos2d_chipmunk.build/Objects-normal/i386/CCScheduler.d --serialize-diagnostics /Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/test_cocos2d_chipmunk.build/Debug-iphonesimulator/test_cocos2d_chipmunk.build/Objects-normal/i386/CCScheduler.dia -c /Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/CCScheduler.cpp -o /Users/joel-lamotte/Library/Developer/Xcode/DerivedData/test_cocos2d_chipmunk-cylofdoywsnrhedrhdydeyccapdl/Build/Intermediates/test_cocos2d_chipmunk.build/Debug-iphonesimulator/test_cocos2d_chipmunk.build/Objects-normal/i386/CCScheduler.o
In file included from /Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/CCScheduler.cpp:32:
In file included from /Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/include/CCScriptSupport.h:30:
In file included from /Users/joel-lamotte/projects/Test/test_cocos2d_chipmunk/test_cocos2d_chipmunk/libs/cocos2dx/include/CCSet.h:28:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/set:338:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__tree:16:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/memory:592:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:157:8: error: no member named 'uint8_t' in the global namespace
using::uint8_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:158:8: error: no member named 'uint16_t' in the global namespace
using::uint16_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:159:8: error: no member named 'uint32_t' in the global namespace
using::uint32_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:160:8: error: no member named 'uint64_t' in the global namespace
using::uint64_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:162:8: error: no member named 'int_least8_t' in the global namespace
using::int_least8_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:163:8: error: no member named 'int_least16_t' in the global namespace
using::int_least16_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:164:8: error: no member named 'int_least32_t' in the global namespace
using::int_least32_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:165:8: error: no member named 'int_least64_t' in the global namespace
using::int_least64_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:167:8: error: no member named 'uint_least8_t' in the global namespace
using::uint_least8_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:168:8: error: no member named 'uint_least16_t' in the global namespace
using::uint_least16_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:169:8: error: no member named 'uint_least32_t' in the global namespace
using::uint_least32_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:170:8: error: no member named 'uint_least64_t' in the global namespace
using::uint_least64_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:172:8: error: no member named 'int_fast8_t' in the global namespace
using::int_fast8_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:173:8: error: no member named 'int_fast16_t' in the global namespace
using::int_fast16_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:174:8: error: no member named 'int_fast32_t' in the global namespace
using::int_fast32_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:175:8: error: no member named 'int_fast64_t' in the global namespace
using::int_fast64_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:177:8: error: no member named 'uint_fast8_t' in the global namespace
using::uint_fast8_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:178:8: error: no member named 'uint_fast16_t' in the global namespace
using::uint_fast16_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstdint:179:8: error: no member named 'uint_fast32_t' in the global namespace
using::uint_fast32_t;
~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
As said I only get this problem with cocos2d-x projects, not, for example with console applications.
I hunted the problem all day without finding anything.