在C+中使用目标IPHONE模拟器时发生链接器错误+; TojiToiPixeSimuleMe宏在添加到项目中的C++源中不起作用。但是应该注意的是,如果我简单地用1或0更改宏,代码就会运行

在C+中使用目标IPHONE模拟器时发生链接器错误+; TojiToiPixeSimuleMe宏在添加到项目中的C++源中不起作用。但是应该注意的是,如果我简单地用1或0更改宏,代码就会运行,c++,ios,objective-c,xcode,linker-errors,C++,Ios,Objective C,Xcode,Linker Errors,这就是设置。我一直在转换以下文件: 使用我在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_I

这就是设置。我一直在转换以下文件: 使用我在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
\ifndef TWEAKVAL\u H
#定义参数val_H
#ifdef_uucplusplus
外部“C”{
#恩迪夫
#包括
//仅在模拟器上的调试版本中执行,这在iOS设备上不起作用
#如果目标为IPHONE模拟器//则替换为1或0以使其正常工作
#定义电视\u使用\u调整值1
#否则
#定义电视\u使用\u调整值0
#恩迪夫
//
//有关如何实现的想法,请参见上面引用的线程
//这不需要_计数器_宏。
//如果我们处于需要tweakval和编译器的构建模式
//支持它,使用它
#如果电视使用
#定义TV(Val)TweakValue(uuu文件uuu,uuu计数器uu,Val)
//浮点值(常量字符*文件、大小计数器、浮点值);
int _TweakValue(常量字符*文件、大小计数器、int origVal);
void reloadChangedWeakableValues();
#否则
//不要用它
#定义电视(Val)Val
#定义重新加载的ChangedWeakableValues()
#恩迪夫
#ifdef_uucplusplus
}//外部“C”
#恩迪夫
#恩迪夫
cpp文件几乎完全相同,只是整个文件都用#if TV_USE_TWEAKVAL包装

现在我可以通过代码或在构建设置中手动设置这个宏,但我更喜欢通过检测预处理器命令来自动启用/禁用这个宏。我的猜测是,宏在链接tweakval源代码时没有被检测到,我不知道需要更改哪些构建设置来解决此问题


谢谢。

TARGET\u IPHONE\u模拟器
来自
TargetConditionals.h
。您需要
#包含该文件。您的其他代码可能通过其他路径间接获得它,如
Cocoa/Cocoa.h