c++ - 无法在 C++/Objective-C++ 代码中设置断点

标签 c++ xcode objective-c++

我正在尝试在我的 objective-c ++(我认为是调用的)代码中设置一个断点。

我已经使用#ifdef _cplusplus#endif 来包装代码,但是当我在其中设置断点时,它会在结束时中断方法主体,主体中的代码均未运行。

Bad breakpoints :/

我已经简化了我的代码,但我希望至少能看到由于 cout 而在控制台中打印的数字。

该文件的扩展名也是 .mm。我是混合 C++ 和 Objective-C 的新手。我错过了什么吗?

最佳答案

#ifdef 是一个 preprocessor directive - 简而言之,这意味着没有 _cplusplus 在某处被 #defined,你的调试器足够聪明,可以说 嘿,这是死代码 - 甚至不尝试调试它

Preprocessor directives are lines included in the code of programs preceded by a hash sign (#). These lines are not program statements but directives for the preprocessor. The preprocessor examines the code before actual compilation of code begins and resolves all these directives before any code is actually generated by regular statements.

These preprocessor directives extend only across a single line of code. As soon as a newline character is found, the preprocessor directive is ends. No semicolon (;) is expected at the end of a preprocessor directive. The only way a preprocessor directive can extend through more than one line is by preceding the newline character at the end of the line by a backslash ().

这些非常有用,对于常见示例,请快速查看 Include Guards .作为测试以了解我的意思,请尝试在 #ifdef 的正上方添加 #define _cplusplus,然后重试。

关于c++ - 无法在 C++/Objective-C++ 代码中设置断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23165297/

相关文章:

c++ - Objective-C++ 无法使用 MyType *__strong 类型的左值初始化类型为 id<...> 的参数,即使它符合协议(protocol)

C++ 双下标重载 : cannot convert from 'type' to 'type &'

ios - 如何使用 iOS 应用程序向 Active Directory 进行身份验证

iOS Storyboards 我应该使用它们吗?

c++ - 在 XCode 中创建要在 Obj-C 中使用的 C++ 库

objective-c - XCode 4 是否支持区域以及您的代码管理方法是什么?

c++ - Qt在ComboBox1的基础上改变ComboBox2

c++ - 迭代 C++ 列表中一对(或元组)的特定项

c++ - boost 几何/空间查询形状

xcodebuild 不构建对 Mountain Lion、Xcode 4.5 的依赖