Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix atomicops build failure on non-Clang #27

Merged
merged 1 commit into from
Sep 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/google/protobuf/stubs/atomicops.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,14 @@ GOOGLE_PROTOBUF_ATOMICOPS_ERROR
#include <google/protobuf/stubs/atomicops_internals_mips_gcc.h>
#elif defined(__native_client__)
#include <google/protobuf/stubs/atomicops_internals_pnacl.h>
#elif (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4)) || \
(defined(__clang__) && __has_extension(c_atomic))
#elif (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4))
#include <google/protobuf/stubs/atomicops_internals_generic_gcc.h>
#elif defined(__clang__)
#if __has_extension(c_atomic)
#include <google/protobuf/stubs/atomicops_internals_generic_gcc.h>
#else
GOOGLE_PROTOBUF_ATOMICOPS_ERROR
#endif
#else
GOOGLE_PROTOBUF_ATOMICOPS_ERROR
#endif
Expand Down
18 changes: 13 additions & 5 deletions src/google/protobuf/stubs/platform_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@

#include <google/protobuf/stubs/common.h>

#define GOOGLE_PROTOBUF_PLATFORM_ERROR \
#error "Host platform was not detected as supported by protobuf"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this macro only contain the string literal? I remember "#define XXX #error" doesn't compile on some platforms (likely to be VC on windows).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the style from https://github.com/google/protobuf/blob/v2.6.0/src/google/protobuf/stubs/atomicops.h#L163, so there is already an instance of that construct in the code base :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'm not quite sure what you're asking for. Do you want the end result to be a bare string constant, causing a syntax error, rather than using #error at all?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was suggesting:
#define PLATFORM_ERROR "Host platform ..."
and then
#error PLATFORM_ERROR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be ok if such "#define XXX #error" is already used elsewhere in protobuf. I'll merge the patch.


// Processor architecture detection. For more info on what's defined, see:
// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
// http://www.agner.org/optimize/calling_conventions.pdf
Expand Down Expand Up @@ -62,17 +65,22 @@
#endif
#elif defined(__pnacl__)
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1
#elif defined(__GNUC__) && \
((((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4)) || \
(defined(__clang__) && __has_extension(c_atomic)))
// We fallback to the generic GCC >= 4.7 implementation in atomicops.h
#elif defined(__GNUC__)
# if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4))
// We fallback to the generic Clang/GCC >= 4.7 implementation in atomicops.h
# elif defined(__clang__)
# if !__has_extension(c_atomic)
GOOGLE_PROTOBUF_PLATFORM_ERROR
# endif
// We fallback to the generic Clang/GCC >= 4.7 implementation in atomicops.h
# endif
# if __LP64__
# define GOOGLE_PROTOBUF_ARCH_64_BIT 1
# else
# define GOOGLE_PROTOBUF_ARCH_32_BIT 1
# endif
#else
#error Host architecture was not detected as supported by protobuf
GOOGLE_PROTOBUF_PLATFORM_ERROR
#endif

#if defined(__APPLE__)
Expand Down