输入'uint32_t'无法解析 [英] Type 'uint32_t' could not be resolved

查看:1414
本文介绍了输入'uint32_t'无法解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Eclipse(3.8.1)CDT中开发一个C ++程序。我在Debian 8上使用了gcc编译器。我还使用了一个名为opendnp3的开放源代码库,用C ++编写,它需要 uint32_t 来解决,因为它是几个方法调用和构造函数中的一个参数。 p>

在opendnp对象中,intellisense不包含列表

__ uint32_t 然而,请解决。



该类型在< cstdint> << ; cstdint> 解析就好了)。我可以打开声明,并在那里清楚地看到' using :: uint32_t; '。



在我的搜索中,我在C / C ++ Build - > Settings - > Tool Settings - > GCC C ++ Compiler下添加了 -std = c ++ 11 到'All options'我也重建了项目索引并重新启动了Eclipse,但仍无法解决。



以下是目前的代码:编辑为简单的HelloWorld项目以帮助诊断问题

  #include< iostream> 
#include< cstdint> //有uint32_t使用namespace std定义了
;

int main(){
__uint32_t t = 0; //解析就好了
uint32_t i = 0; //类型无法解析
auto x =123; // C ++ 11正在工作
cout<< 富! << ENDL; //打印Foo!
返回0;

制作尝试后的CDT控制台:



23:10:52 ****增量构建配置调试项目FOO ****
使所有
make:无需为全部完成
p>

23:10:52构建完成(需要133毫秒)

解决方案

I知道这个问题已经过时了,但我觉得值得一提的是,我有这个确切的问题,并且能够解决它只是重建索引:右键单击项目,索引,重建。你说你已经重建了索引,但没有帮助;重要的是,在CDT GCC内置编译器设置中指定的编译器的命令行中添加了 -std = c ++ 11 后,我可以做到这一点通过打开项目属性并转到C / C ++常规,预处理器包含路径,宏等,提供者选项卡。如果我理解正确,你不会,因为它默认为C ++ 14,所以需要使用GCC版本6+来执行此操作;我自己使用GCC 5.4。
$ b 如果这样做没有帮助,调试问题的最佳途径可能是打开的声明, cstdint (包含文件本身 - 所以,右键点击 #include 指令中的 cstdint ,并选择打开声明) - 这会向你显示包含的文件,如果通过预处理器宏( #ifdef 等)排除了这些文件,则会显示灰色部分。您可能会立即看到为什么 uint32_t 不被定义。在我的情况下, __ cplusplus 宏的值不合适,这导致我添加 -std = c ++ 11 到上面提到的编译器命令行 - 但是我仍然需要在问题完全解决之前重建索引。


I am working on a C++ program in Eclipse (3.8.1) CDT. I am using the gcc compiler on Debian 8. I'm also using an open source library called opendnp3 written in C++, which requires uint32_t to resolve as it's a parameter in several method calls and constructors.

In the opendnp objects, intellisense doesnt list

__uint32_t however, DOES resolve.

The type is defined in <cstdint> (<cstdint> resolves just fine). I can open the declaration and clearly see 'using ::uint32_t;' in there.

In my searching, I've added -std=c++11 to 'All options' under 'C/C++ Build --> Settings -> Tool Settings -> GCC C++ Compiler' and I've also rebuilt the project index and restarted Eclipse, but it still doesn't resolve.

Here's the code so far: Edited to a simple HelloWorld project to help diagnose problem

#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 Console after a build attempt:

23:10:52 **** Incremental Build of configuration Debug for project FOO **** make all make: Nothing to be done for 'all'.

23:10:52 Build Finished (took 133ms)

解决方案

I know this question is old, but I feel it's worth mentioning that I was having this exact problem and was able to resolve it just be rebuilding the index: right-click the project, "Index", "Rebuild". You said that you had rebuilt the index and it didn't help; importantly, I did this after adding -std=c++11 to the command line for the compiler specified in the "CDT GCC Built-in Compiler Settings", which can be found by opening project properties and going to "C/C++ General", "Preprocessor Include Paths, Macros etc", "Providers" tab. You wouldn't, if I understand correctly, need to do this with GCC version 6+ as it defaults to C++14; I'm using GCC 5.4 myself.

If that doesn't help, the best path for debugging the issue is probably to open the declaration for cstdint (the include file itself - so, right click cstdint within the #include directive, and choose "open declaration") - this will show you the included file, with sections greyed out if they are precluded via preprocessor macros (#ifdef and the like). You may be able to see immediately why uint32_t is not considered defined. In my case, the __cplusplus macro had an unsuitable value and this led me to adding -std=c++11 to the compiler command line as mentioned above - but I still needed to rebuild the index before the problem was fully resolved.

这篇关于输入'uint32_t'无法解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆