Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the equivalent of int32_t in Visual C++?

Tags:

c++

visual-c++

What's the equivalent of int32_t in Visual C++?

like image 214
kevin Avatar asked Apr 14 '11 02:04

kevin


2 Answers

Visual C++ 2010 include <cstdint>, which includes typedef std::int32_t (you can also include <stdint.h> which has the same typedef in the global namespace).

If you are using an older version of Visual C++, you can use Boost's <cstdint> implementation.

like image 167
James McNellis Avatar answered Sep 20 '22 06:09

James McNellis


What I do is make my own typedefs after making sure the types exist like so:

#ifdef _MSC_VER
    #if _MSC_VER >= 1600
        #include <cstdint>
    #else
        typedef __int8              int8_t;
        typedef __int16             int16_t;
        typedef __int32             int32_t;
        typedef __int64             int64_t;
        typedef unsigned __int8     uint8_t;
        typedef unsigned __int16    uint16_t;
        typedef unsigned __int32    uint32_t;
        typedef unsigned __int64    uint64_t;
    #endif
#elif __GNUC__ >= 3
    #include <cstdint>
#endif

typedef int8_t      s8;
typedef int16_t     s16;
typedef int32_t     s32;
typedef int64_t     s64;
typedef uint8_t     u8;
typedef uint16_t    u16;
typedef uint32_t    u32;
typedef uint64_t    u64;
like image 35
Jimmio92 Avatar answered Sep 19 '22 06:09

Jimmio92