cocoscreator 怎么在C++层判断是不是android平台

cocoscreator 3.6.0, 我想接入Bugly, 监听一下Log报错日志,在文件 Creator\3.6.0\resources\resources\3d\engine\native\cocos\bindings\jswrapper\config.cpp里修改selogMessage方法如下:
void selogMessage(cc::LogLevel level, const char *tag, const char *format, …) {

char logbuf[512] = {0};

va_list argp;

va_start(argp, format);

(void)std::vsnprintf(logbuf, sizeof(logbuf), format, argp);

va_end(argp);

cc::Log::logMessage(cc::LogType::KERNEL, level, "%s %s", tag, logbuf);

if(level == cc::LogLevel::ERR) {

#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)

    JniHelper::callStaticVoidMethod("com/cocos/game/BuglyAgent", "postException",  5, "message", "reason", logbuf);

#endif

}

}
但是这个#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)这个判断好像根本就无效,调试时发现无论如何都跳过去了,请问这是怎么回事啊,怎么在C++层判断是不是android平台?

跟一下jni的头文件 看看怎么引用的 肯定有宏隔离开了


log文件直接有判断的。我也是在这里把错误日志上报上去

宏错了

(CC_PLATFORM == CC_PLATFORM_ANDROID)

另外,你那种有点侵入式修改引擎,如bugly只是想捕获JS引擎的错误,推荐以下方式

    se::ScriptEngine* se = se::ScriptEngine::getInstance();
se->setExceptionCallback([](const char* location, const char* message, const char* stack){
    // Send exception information to server like Tencent Bugly.

});