aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/stubs/port.h
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2016-07-25 10:52:44 -0700
committerGravatar Feng Xiao <xfxyjwf@gmail.com>2016-07-25 13:18:38 -0700
commita17367f44a3b592993d2ac5c074ed58fb0ce784c (patch)
tree6437f0c99af98fe066a134bbb828b42981d4150f /src/google/protobuf/stubs/port.h
parent868ea59256b999175ba04c1b9cfe74ff1fbae13d (diff)
Define intX as standard exact-width integer types.
Fixes https://github.com/google/protobuf/issues/823 Change-Id: I7f4c2bfcac2f81d8b34c030dd3d12ea02aaa2264
Diffstat (limited to 'src/google/protobuf/stubs/port.h')
-rw-r--r--src/google/protobuf/stubs/port.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h
index 328258b7..371806f1 100644
--- a/src/google/protobuf/stubs/port.h
+++ b/src/google/protobuf/stubs/port.h
@@ -109,15 +109,15 @@ typedef unsigned __int16 uint16;
typedef unsigned __int32 uint32;
typedef unsigned __int64 uint64;
#else
-typedef signed char int8;
-typedef short int16;
-typedef int int32;
-typedef long long int64;
-
-typedef unsigned char uint8;
-typedef unsigned short uint16;
-typedef unsigned int uint32;
-typedef unsigned long long uint64;
+typedef int8_t int8;
+typedef int16_t int16;
+typedef int32_t int32;
+typedef int64_t int64;
+
+typedef uint8_t uint8;
+typedef uint16_t uint16;
+typedef uint32_t uint32;
+typedef uint64_t uint64;
#endif
// long long macros to be used because gcc and vc++ use different suffixes,
@@ -131,8 +131,10 @@ typedef unsigned long long uint64;
#define GOOGLE_ULONGLONG(x) x##UI64
#define GOOGLE_LL_FORMAT "I64" // As in printf("%I64d", ...)
#else
-#define GOOGLE_LONGLONG(x) x##LL
-#define GOOGLE_ULONGLONG(x) x##ULL
+// By long long, we actually mean int64.
+#define GOOGLE_LONGLONG(x) INT64_C(x)
+#define GOOGLE_ULONGLONG(x) UINT64_C(x)
+// Used to format real long long integers.
#define GOOGLE_LL_FORMAT "ll" // As in "%lld". Note that "q" is poor form also.
#endif