我正在尝试从AdMob的本机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);
}
答案 0 :(得分: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
。我不确定为什么在同一文件中不会失败。解决此呼叫后,它可能会失败。