1. 程式人生 > >解決VC2015包含stdint.h標頭檔案衝突問題

解決VC2015包含stdint.h標頭檔案衝突問題

stdint.h是C99的標準,主要用於統一跨平臺資料定義。
MSVC中不帶有這個標頭檔案,直到VS2010。在之前的版本里面,我們可以:
(1)下載這個標頭檔案
download a MS version of this header from:http://msinttypes.googlecode.com/svn/trunk/stdint.hA portable one can be found here:http://www.azillionmonkeys.com/qed/pstdint.h
(2)將標頭檔案放到(以VS2015為例):
C:\Program Files\Microsoft Visual Studio 14.0\VC\include
出現“C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdint.h(17): error C2632: “char”後面的“char”非法”錯誤。stdint.h檔案17行是typedef signed char        int8_t;
解決方法:
先查詢工程中引用int8_t的地方,遮蔽掉這段程式碼,增加 #include <cstdint>總的解決方法如下:
Features of C standard Library are also provided in the C++ Standard library and as a general naming convention they are pre-pended by an c to the corresponding names in C standard library.
In C++, You should be using:
#include <cstdint>
and fully qualify the symbol names you use with std::
while in C, You should use:
#include <stdint.h>https://stackoverflow.com/questions/13642827/cstdint-vs-stdint-h