【发布时间】:2016-09-24 19:25:29
【问题描述】:
我正在 Eclipse (3.8.1) CDT 中开发 C++ 程序。我在 Debian 8 上使用 gcc 编译器。我还使用了一个用 C++ 编写的名为 opendnp3 的开源库,它需要 uint32_t 来解析,因为它是多个方法调用和构造函数中的参数。
在 opendnp 对象中,intellisense 不列出
__uint32_t 但是,确实可以解决。
类型在<cstdint> 中定义(<cstdint> 解析得很好)。我可以打开声明并清楚地看到“using ::uint32_t;”。
在我的搜索中,我在“C/C++ Build --> Settings -> Tool Settings -> GCC C++ Compiler”下的“All options”中添加了-std=c++11,并且我还重建了项目索引并重新启动Eclipse,但它仍然没有解决。
到目前为止的代码如下:编辑为一个简单的 HelloWorld 项目以帮助诊断问题
#include <iostream>
#include <cstdint> //has uint32_t defined
using namespace std;
int main() {
__uint32_t t = 0; //resolves just fine
uint32_t i = 0; //Type could not be resolved
auto x = "123"; //C++ 11 working
cout << "Foo!" << endl; // prints Foo!
return 0;
}
构建尝试后的 CDT 控制台:
23:10:52 **** 项目 FOO 的配置调试的增量构建 **** 做所有 make: 'all' 无事可做。
23:10:52 构建完成(耗时 133 毫秒)
【问题讨论】:
-
"我在 Debian 8 上使用 gcc 编译器。"那是什么gcc版本?您可以通过
gcc -v查看。 -
这是导致编译错误还是只是 Eclipse UI 正在标记错误?
-
试试
std::uint32_t。在using namespace yyy;的弹幕中可能有不止一个xxx::uint32_t,这使得名称模棱两可。 -
尝试将#include
//uint32_t 移动到第一行。 opendnp3 如何引用 uint32_t ? -
是时候解决问题了。如果
#include <iostream> #include <cstdint> int main() { uint32_t test =0; std::cout << test << std::endl; }没有重现问题,那么@BaummitAugen 可能是对的。
标签: c++ eclipse c++11 gcc eclipse-cdt