'uint32_t' identifier not found error

后端 未结 7 1813
情话喂你
情话喂你 2020-12-07 23:41

I\'m porting code from Linux C to Visual C++ for windows.

Visual C++ doesn\'t know #include so I commented it out.

Later, I fou

相关标签:
7条回答
  • 2020-12-08 00:14

    I have the same error and it fixed it including in the file the following

    #include <stdint.h>
    

    at the beginning of your file.

    0 讨论(0)
  • 2020-12-08 00:20

    Boost.Config offers these typedefs for toolsets that do not provide them natively. The documentation for this specific functionality is here: Standard Integer Types

    0 讨论(0)
  • 2020-12-08 00:25

    This type is defined in the C header <stdint.h> which is part of the C++11 standard but not standard in C++03. According to the Wikipedia page on the header, it hasn't shipped with Visual Studio until VS2010.

    In the meantime, you could probably fake up your own version of the header by adding typedefs that map Microsoft's custom integer types to the types expected by C. For example:

    typedef __int32 int32_t;
    typedef unsigned __int32 uint32_t;
    /* ... etc. ... */
    

    Hope this helps!

    0 讨论(0)
  • 2020-12-08 00:25

    I had to run project in VS2010 and I could not introduce any modifications in the code. My solution was to install vS2013 and in VS2010 point VC++ Directories->IncludeDirectories to Program Files(x86)\Microsoft Visual Studio 12.0\VC\include. Then my project compiled without any issues.

    0 讨论(0)
  • 2020-12-08 00:29

    There is an implementation available at the msinttypes project page - "This project fills the absence of stdint.h and inttypes.h in Microsoft Visual Studio".

    I don't have experience with this implementation, but I've seen it recommended by others on SO.

    0 讨论(0)
  • 2020-12-08 00:30

    On Windows I usually use windows types. To use it you have to include <Windows.h>.

    In this case uint32_t is UINT32 or just UINT.

    All types definitions are here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751%28v=vs.85%29.aspx

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