'CCMessageBox' was not declared in this scope

'CCMessageBox' was not declared in this scope
0.0 0



Im starting using cocos2dx. When running build_native.sh for building proj.android (inside cygwin, using ndk 7c), i’m getting this error:

C:/cocos2dx/cocos2d-x-gles20/testproj/proj.android/../../cocos2dx/script_support/CCScriptSupport.cpp: In function 'void cc_assert_script_compatible(bool, const char*)':
C:/cocos2dx/cocos2d-x-gles20/testproj/proj.android/../../cocos2dx/script_support/CCScriptSupport.cpp:36: error: 'CCMessageBox' was not declared in this scope
/cygdrive/c/cocos2dx/android-ndk-r7c/build/core/build-binary.mk:243: recipe for target `obj/local/armeabi/objs/cocos2dx_static/script_support/CCScriptSupport.o' failed
make: *** [obj/local/armeabi/objs/cocos2dx_static/script_support/CCScriptSupport.o] Error 1
make: se sale del directorio `/cygdrive/c/cocos2dx/cocos2d-x-gles20/testproj/proj.android'

What could be the problem? The error appears when calling CC_ASSERT function.

Thanks a lot in advance!


Hi, I found the problem

in file platform\android\CCPlatformDefine.h, there is a macro defined as:

#define CC_ASSERT(cond) \
if (! (cond)) \
{ \
    char content[256]; \
    sprintf(content, "%s function:%s line:%d", __FILE__, __FUNCTION__, __LINE__);  \
    CCMessageBox(content, "Assert error"); \

The problem is that the CCMessageBox function, exists within namespace cocos2d. As the CC_ASSERT is called from CCScriptSupport.cpp, outside the USING_NS_CC declaration, it does not work.

I solved this issue by adding cocos2d:: before CCMessageBox call in file platform\android\CCPlatformDefine.h.

Hope this helps, maybe someone should add a new ticket for this.



thinks a lot for this, I also found the problem, long time no out.