'uint32_t' does not name a type

后端 未结 9 1618
旧时难觅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 13:08

    I had tha same problem trying to compile a lib I download from the internet. In my case, there was already a #include <cstdint> in the code. I solved it adding a:

    using std::uint32_t;
    
    0 讨论(0)
  • 2021-01-30 13:09

    The other answers assume that your compiler is C++11 compliant. That is fine if it is. But what if you are using an older compiler?

    I picked up the following hack somewhere on the net. It works well enough for me:

      #if defined __UINT32_MAX__ or UINT32_MAX
      #include <inttypes.h>
      #else
      typedef unsigned char uint8_t;
      typedef unsigned short uint16_t;
      typedef unsigned long uint32_t;
      typedef unsigned long long uint64_t;
      #endif
    

    It is not portable, of course. But it might work for your compiler.

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

    Add the following in the base.mk file. The following 3rd line is important -include $(TOP)/defs.mk

    CFLAGS=$(DEBUG) -Wall -W -Wwrite-strings 
    CFLAGS_C=-Wmissing-prototypes
    CFLAGS_CXX=-std=c++0x
    LDFLAGS=
    LIBS=
    

    to avoid the #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options

    0 讨论(0)
提交回复
热议问题