0
TARGET_IPHONE_SIMULATOR宏在我添加到項目中的C++源中不起作用。雖然應該注意的是,代碼運行,如果我只是更換1或0的宏。在C++中使用TARGET_IPHONE_SIMULATOR時發生鏈接錯誤
所以這裏的設置。我一直在將文件從: https://code.google.com/p/ld48jovoc/source/browse/util/tweakval/?r=13轉換爲我在XCode中製作的iOS應用程序。
除了標題,一切都差不多。
#ifndef TWEAKVAL_H
#define TWEAKVAL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h>
// Do only in debug builds on simulator, this does NOT work on iOS device
#if TARGET_IPHONE_SIMULATOR // replace with 1 or zero to make it work
# define TV_USE_TWEAKVAL 1
#else
# define TV_USE_TWEAKVAL 0
#endif
//
// See the thread referenced above for idea of how to implement
// this without the __COUNTER__ macro.
// If we are in a build modethat wants tweakval, and the compiler
// supports it, use it
#if TV_USE_TWEAKVAL
# define _TV(Val) _TweakValue(__FILE__, __COUNTER__, Val)
//float _TweakValue(const char *file, size_t counter, float origVal);
int _TweakValue(const char *file, size_t counter, int origVal);
void ReloadChangedTweakableValues();
#else
// don't use it
# define _TV(Val) Val
# define ReloadChangedTweakableValues()
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif
cpp文件幾乎完全相同,只是整個東西被封裝在#if TV_USE_TWEAKVAL中。
現在我可以手動設置這個宏,通過代碼或在構建設置,但我更喜歡讓這個東西通過檢測預處理器命令自動啓用/禁用。我的猜測是,當它連接調整的源代碼時,宏沒有被檢測到,我不知道我需要更改哪些構建設置來解決此問題。
謝謝。
我是個白癡。謝謝。 – Biclops