作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试从 AdMob 的 native iOS 代码实现回调,这是我的代码,com_manyukhin_cerebrate_words_synonyms_NativeInterstitialAdsInterfaceImpl.h:
#include "CodenameOne_GLViewController.h"
#include "com_manyukhin_cerebrate_words_synonyms_WordsSynonyms.h"
com_manyukhin_cerebrate_words_synonyms_NativeInterstitialAdsInterfaceImpl.m:
#import "com_manyukhin_cerebrate_words_synonyms_NativeInterstitialAdsInterfaceImpl.h"
- (void) interstitialDidDismissScreen:(GADInterstitial *)ad {
com_manyukhin_cerebrate_words_synonyms_WordsSynonyms_onInterstitialClosed__(CN1_THREAD_STATE_PASS_SINGLE_ARG);
}
但我遇到了引用 CN1_THREAD_STATE_PASS_SINGLE_ARG 定义的编译错误:
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build6871177334585892440xxx/dist/WordsSynonyms-src/com_manyukhin_cerebrate_words_synonyms_NativeInterstitialAdsInterfaceImpl.m:59:78: error: use of undeclared identifier 'threadStateData'
com_manyukhin_cerebrate_words_synonyms_WordsSynonyms_onInterstitialClosed__(CN1_THREAD_STATE_PASS_SINGLE_ARG);
^
In file included from /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build6871177334585892440xxx/dist/WordsSynonyms-src/com_manyukhin_cerebrate_words_synonyms_NativeInterstitialAdsInterfaceImpl.m:1:
In file included from /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build6871177334585892440xxx/dist/WordsSynonyms-src/WordsSynonyms-Prefix.pch:18:
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build6871177334585892440xxx/dist/WordsSynonyms-src/cn1_globals.h:781:42: note: expanded from macro 'CN1_THREAD_STATE_PASS_SINGLE_ARG'
#define CN1_THREAD_STATE_PASS_SINGLE_ARG threadStateData
^
有什么解决办法吗?
有趣的是,同一 .m 文件中的以下代码(不同的宏)不会触发错误:
- (void) interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error {
com_manyukhin_cerebrate_words_synonyms_WordsSynonyms_onInterstitialFaliedToLoad___int(CN1_THREAD_GET_STATE_PASS_ARG -1);
}
最佳答案
这些是这样定义的:
#define CODENAME_ONE_THREAD_STATE struct ThreadLocalData* threadStateData
#define CN1_THREAD_STATE_SINGLE_ARG CODENAME_ONE_THREAD_STATE
#define CN1_THREAD_STATE_MULTI_ARG CODENAME_ONE_THREAD_STATE,
#define CN1_THREAD_STATE_PASS_ARG threadStateData,
#define CN1_THREAD_STATE_PASS_SINGLE_ARG threadStateData
#define CN1_THREAD_GET_STATE_PASS_ARG getThreadLocalData(),
#define CN1_THREAD_GET_STATE_PASS_SINGLE_ARG getThreadLocalData()
所以你需要使用CN1_THREAD_GET_STATE_PASS_SINGLE_ARG
。我不确定为什么在同一个文件中不会失败。一旦您修复此调用,它可能会失败。
关于iOS native 代码编译错误,使用未声明的标识符 'threadStateData',从宏 'CN1_THREAD_STATE_PASS_SINGLE_ARG' 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54206305/
我正在尝试从 AdMob 的 native iOS 代码实现回调,这是我的代码,com_manyukhin_cerebrate_words_synonyms_NativeInterstitialAds
我是一名优秀的程序员,十分优秀!