【问题标题】:_int64 does not name a type_int64 没有命名类型
【发布时间】:2011-08-24 11:18:11
【问题描述】:

在我的 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 没有命名类型。可能是什么问题?

【问题讨论】:

    标签: iphone int64 pch


    【解决方案1】:

    添加此包含

    #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;  
    

    【讨论】:

    • 不需要写 typedef signed __ ?
    • 之后如果你在任何地方使用 int64_t 那么编译器会理解有符号的 __int64
    【解决方案2】:

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

    【讨论】:

    • 其实我正在构建this代码。
    猜你喜欢
    • 2022-01-21
    • 2023-04-07
    • 2021-02-03
    • 2017-04-01
    • 2015-06-09
    • 2016-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多