diff options
author | Douglas Heriot <douglas@douglasheriot.com> | 2015-08-22 02:05:40 +1000 |
---|---|---|
committer | Douglas Heriot <douglas@douglasheriot.com> | 2015-08-22 02:05:40 +1000 |
commit | 5021c4d88506ac19be4302be02c3cd1702f97d03 (patch) | |
tree | 901d4932207a1a2988aff54bdc66f652dde6b07c /src/google/protobuf/stubs/port.h | |
parent | 0cb84ee31fc2ac6e6f07c76a5dc20a20272d7516 (diff) | |
download | protobuf-5021c4d88506ac19be4302be02c3cd1702f97d03.tar.gz protobuf-5021c4d88506ac19be4302be02c3cd1702f97d03.tar.bz2 protobuf-5021c4d88506ac19be4302be02c3cd1702f97d03.zip |
Define GOOGLE_ATTRIBUTE_NOINLINE for MSVC. Workaround for VS2015 Release build compiler bug.
See issue #240 - MSVC in VS2015 seems to inline a function it shouldn't. My original workaround was to disable inlining for the whole file, but I found a way to do it on just this specific function using __declspec(noinline).
Unfortunately __declspec has to go at the start of the function declaration, while __attribute in GCC can go either before or after. I had to move lots of GOOGLE_ATTRIBUTE_NOLINE to make it compile. I have not yet tested this change with GCC.
Will there be other side effects of defining this, given it wasn't previously?
I also noticed a few functions marked with both the 'inline' keyword, and GOOGLE_ATTRIBUTE_NOINLINE - huh? Is there an explanation for this, or is it an oversight?
Diffstat (limited to 'src/google/protobuf/stubs/port.h')
-rw-r--r-- | src/google/protobuf/stubs/port.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 8a5d1a13..a3c53dd9 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -161,6 +161,9 @@ static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF); // For functions we want to force not inline. // Introduced in gcc 3.1. #define GOOGLE_ATTRIBUTE_NOINLINE __attribute__ ((noinline)) +#elif defined(_MSC_VER) && (_MSC_VER >= 1400) +// Seems to have been around since at least Visual Studio 2005 +#define GOOGLE_ATTRIBUTE_NOINLINE __declspec(noinline) #else // Other compilers will have to figure it out for themselves. #define GOOGLE_ATTRIBUTE_NOINLINE |