8

在我的pch文件中,我有以下定义:

#if (_MSC_VER < 1300)
   typedef signed char       int8_t;
   typedef signed short      int16_t;
   typedef signed int        int32_t;
   typedef unsigned char     uint8_t;
   typedef unsigned short    uint16_t;
   typedef unsigned int      uint32_t;
#else
   typedef signed __int8     int8_t;
   typedef signed __int16    int16_t;
   typedef signed __int32    int32_t;
   typedef unsigned __int8   uint8_t;
   typedef unsigned __int16  uint16_t;
   typedef unsigned __int32  uint32_t;
#endif
typedef signed __int64       int64_t;
typedef unsigned __int64     uint64_t;  

当我构建我的应用程序时,出现错误

typedef signed __int64       int64_t;
typedef unsigned __int64     uint64_t; 

它说 _int64 没有命名 type。可能是什么问题?

4

2 回答 2

8

添加这个包括

#include <inttypes.h>

然后使用 uint64_t 或 int64_t。

见下文

#include <inttypes.h>


#if (_MSC_VER < 1300)
   typedef signed char       int8_t;
   typedef signed short      int16_t;
   typedef signed int        int32_t;
   typedef unsigned char     uint8_t;
   typedef unsigned short    uint16_t;
   typedef unsigned int      uint32_t;
#else
   typedef signed __int8     int8_t;
   typedef signed __int16    int16_t;
   typedef signed __int32    int32_t;
   typedef unsigned __int8   uint8_t;
   typedef unsigned __int16  uint16_t;
   typedef unsigned __int32  uint32_t;
#endif
typedef signed __int64       int64_t;
typedef unsigned __int64     uint64_t;  
于 2011-08-24T11:24:03.830 回答
4

看起来您正在尝试将 MSVC 特定__int64类型与 GCC 一起使用。这不起作用,请long long改用。

于 2011-08-24T11:21:29.063 回答