Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type 'uint32_t' could not be resolved

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)

like image 813
ErikJL Avatar asked May 26 '16 16:05

ErikJL


2 Answers

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.

like image 195
davmac Avatar answered Nov 13 '22 12:11

davmac


Try to enable the CDT GCC Built-in Compiler Settings in Project>Properties>Preprocessor Includes>Providers.

like image 4
Laurenz Avatar answered Nov 13 '22 11:11

Laurenz