2011-08-24 28 views
7

Trong pch tập tin của tôi, tôi có định nghĩa sau đây:_int64 không tên một loại

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

Khi tôi xây dựng ứng dụng của tôi, tôi nhận được một lỗi tại

typedef signed __int64  int64_t; 
typedef unsigned __int64  uint64_t; 

mà nói rằng _int64 không đặt tên là loại. Rắc rối có thể là cái gì?

Trả lời

8

Thêm này bao gồm

#include <inttypes.h> 

Sau đó sử dụng uint64_t hoặc int64_t.

xem dưới đây

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

Không cần phải viết typedef đã ký __? – Nitish

+0

sau đó nếu u sử dụng bất cứ nơi nào int64_t sau đó trình biên dịch sẽ hiểu chữ ký __int64 –

+0

Thats không hoạt động. Vẫn gặp lỗi. – Nitish

4

Dường như bạn đang cố gắng sử dụng loại MSVC cụ thể __int64 với GCC. Điều đó không có tác dụng, thay vào đó hãy sử dụng long long.

+0

Thật sự tôi đang xây dựng mã (http://code.google.com/p/idoubs/wiki/Building_iDoubs_v2_x) [này]. – Nitish

Các vấn đề liên quan