从别的c++代码移植到xCode下,代码如下(代码文件是一个.hh文件):
#if defined TOON_CHECK_BOUNDS || defined TOON_TEST_INTERNALS
static inline void check_index(int s, int i)
{
if(i<0 || i >= s)
{
#ifdef TOON_TEST_INTERNALS
throw Internal::BadIndex();
#else
std::cerr << "Toon index out of range" << std::endl;
std::abort();
#endif
}
}
#else
///@internal
///Function used to check bounds.
///By default it does nothing. See \ref sDebug.
static inline void check_index(int, int){}
编译提示:Redefinition of 'check_index'
请问这是什么原因啊?小弟没有做过xCode,不知道这个条件编译在xCode下是否和别的平台处理方式不太一样?请xCode专家解惑~~~~
#if defined TOON_CHECK_BOUNDS || defined TOON_TEST_INTERNALS
static inline void check_index(int s, int i)
{
if(i<0 || i >= s)
{
#ifdef TOON_TEST_INTERNALS
throw Internal::BadIndex();
#else
std::cerr << "Toon index out of range" << std::endl;
std::abort();
#endif
}
}
#else
///@internal
///Function used to check bounds.
///By default it does nothing. See \ref sDebug.
static inline void check_index(int, int){}
编译提示:Redefinition of 'check_index'
请问这是什么原因啊?小弟没有做过xCode,不知道这个条件编译在xCode下是否和别的平台处理方式不太一样?请xCode专家解惑~~~~
解决方案 »
- Xcode连接SVN提交或者更新代码后~内存狂飙,上升到满~
- 关于iphone后台下载的问题
- xcode project navigator里面的路径错了怎么办?
- 关于objective-c 类目(Category),遇到的问题新手求助!
- 新手求教,ios 审核提示无法登陆
- safari不支持Flash播放flv,html5自带video也不行
- 用SmartRF蓝牙开发板和IOS蓝牙如何通信
- 解决 iOS 7 UIBarButtonItem 在 navigationBar 中移位问题
- iOS9.0以后查询正在运行的其他APP
- 关于双击home键多任务列表里的图标问题
- Xcode6运行ios8的项目屏幕右侧不显示内容
- 移植c++代码提示函数没有声明
第二个check_index的参数必须带个名字;
贴出来的代码少了一个#endif
没有#ifdef XXX #define XXX #endif 这个头文件预编译标志,如果用#indclude,有可能会多次包含。除了这些问题,我看不出有其他问题。没有整个项目不好判断。
另外,可以尝试着把函数改个名字,再编译看看。