Index: base/compiler_specific.h |
diff --git a/base/compiler_specific.h b/base/compiler_specific.h |
index a6d9520311f5d0b818cefe8b02d06b4fb71f328f..dfef541e29fd6f7cbcc11d3e03892ccbee5b19bb 100644 |
--- a/base/compiler_specific.h |
+++ b/base/compiler_specific.h |
@@ -56,6 +56,17 @@ |
#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment))) |
#endif |
+// Return the byte alignment of the given type (available at compile time). Use |
+// sizeof(type) prior to checking __alignof to workaround Visual C++ bug: |
+// http://goo.gl/isH0C |
+// Use like: |
+// ALIGNOF(int32_t) // this would be 4 |
+#if defined(COMPILER_MSVC) |
+#define ALIGNOF(type) (sizeof(type) - sizeof(type) + __alignof(type)) |
+#elif defined(COMPILER_GCC) |
+#define ALIGNOF(type) __alignof__(type) |
+#endif |
+ |
#if defined(COMPILER_MSVC) |
#define WARN_UNUSED_RESULT |
#else |