从compile传递的宏无法在eclipse中解析
macro passed from compile cannot be resolved in eclipse
我试图在编译时像这样传递一个定义好的宏给我的程序:
#include <stdio.h>
int main() {
// KEY_CNT is not defined in program but passed at compile time
printf("KEY_CNT: %d", KEY_CNT);
return 0;
}
并使用g++ -DKEY_CNT=2 -O2 test_3.cpp -o test_3
编译,它按预期工作,但问题是Eclipse无法解决'KEY_CNT'。这只是一个玩具的例子,在我最初的程序中,很多像这样的错误是很烦人的。
我认为Eclipse可能需要通知我的编译选项,以便它知道'KEY_CNT'被定义,所以我在Properties -> C/C++ Build -> Settings -> GCC C++ Compiler -> Miscellaneous
中添加-DKEY_CNT=2
,但它仍然不起作用。
有什么建议来解决这个问题吗?
========添加========
Eclipse版本:Eclipse IDE for C/c++ Developers, Luna Service Release 2 (4.4.2)
Properties -> C/c++ Build -> Settings -> GCC c++ Compiler -> Miscellaneous
错误的地方。
应该是"C/c++ Build -> Settings -> GCC c++ Compiler -> Preprocessor"
刚刚验证可以
相关文章:
- 无法在Ubuntu上将共享库与Eclipse链接
- Eclipse CDT:单个项目中有多个C++文件
- C++ 运行时链接器错误 (liblog4cpp.so.5) Eclipse
- Eclipse/Netbeans 中的处理模式行
- 如何在使用 SDL2 的 Eclipse 中构建 c++ 程序
- 使用 Eclipse CDT 进行 Cplex 配置
- Eclipse 没有在 Windows (C++) 中编译.exe
- Compile zbar for Python 3.x
- 在 Eclipse 上启用 C++17 以使用 'std::byte'
- Eclipse CDT clang 工具链 - 无法从链接器选项中删除 stdlibc++,但可以添加 libc++,E
- 在 Eclipse 中添加库的工作方式是否与在 Visual Studio 中相同?
- 将编译器开关添加到 Eclipse CDT 内置编译器设置生成?
- 在 Eclipse: "error: no match for 'operator='" 中获取错误消息
- 在 eclipse 中,将宏重定义视为错误而不是警告
- Eclipse C++ 字符串作为函数参数
- 如何在 Eclipse 中一次从多个源文件进行构建
- Eclipse 可执行架构类型
- Compile bzip2 for Android?
- Compile Error with Eluna - QueryResult.cpp
- 从compile传递的宏无法在eclipse中解析