'uint32_t' does not name a type

后端 未结 9 1617
旧时难觅i
旧时难觅i 2021-01-30 12:13

I\'m trying to compile a C++ software package that was written in 2007 and I\'m getting this error:

error: ‘uint32_t’ does not name a type

This is h

相关标签:
9条回答
  • 2021-01-30 12:45

    You need to #include <cstdint>, but that may not always work.

    The problem is that some compiler often automatically export names defined in various headers or provided types before such standards were in place.

    Now, I said "may not always work." That's because the cstdint header is part of the C++11 standard and is not always available on current C++ compilers (but often is). The stdint.h header is the C equivalent and is part of C99.

    For best portability, I'd recommend using Boost's boost/cstdint.hpp header, if you're willing to use boost. Otherwise, you'll probably be able to get away with #include'ing <cstdint>.

    0 讨论(0)
  • 2021-01-30 12:47

    if it happened when you include opencv header.

    I would recommand that change the order of headers.

    put the opencv headers just below the standard C++ header.

    like this:

    #include<iostream>
    #include<opencv2/core/core.hpp>
    #include<opencv2/highgui/highgui.hpp>
    
    0 讨论(0)
  • 2021-01-30 12:51

    just navigate to /usr/include/x86_64-linux-gnu/bits open stdint-uintn.h and add these lines

    typedef __uint8_t uint8_t;
    typedef __uint16_t uint16_t;
    typedef __uint32_t uint32_t;
    typedef __uint64_t uint64_t;
    

    again open stdint-intn.h and add

    typedef __int8_t int8_t;
    typedef __int16_t int16_t;
    typedef __int32_t int32_t;
    typedef __int64_t int64_t;
    

    note these lines are already present just copy and add the missing lines cheerss..

    0 讨论(0)
  • 2021-01-30 12:58

    I also encountered the same problem on Mac OSX 10.6.8 and unfortunately adding #include <stdint.h> or <cstdint.h> to the corresponding file did not solve my problem. However, after more search, I found this solution advicing to add #include <sys/types.h> which worked well for me!

    0 讨论(0)
  • 2021-01-30 13:06

    You need to include iostream

    #include <iostream>
    using namespace std;
    
    0 讨论(0)
  • 2021-01-30 13:08

    You need to include stdint.h

     #include <stdint.h>
    
    0 讨论(0)
提交回复
热议问题