From b3ca4bccc4fa6b7f5d637bdecb4fac6ca9649f3c Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Fri, 1 Feb 2013 12:36:09 -0800 Subject: Fix build with clang against libstdc++ 4.6 --- src/common/const_array.hpp | 4 ++-- src/common/sanity.hpp | 43 ++++++++++++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 15 deletions(-) (limited to 'src/common') diff --git a/src/common/const_array.hpp b/src/common/const_array.hpp index eb0da58..db8416d 100644 --- a/src/common/const_array.hpp +++ b/src/common/const_array.hpp @@ -28,7 +28,7 @@ #include #include -#ifdef ANNOYING_GCC46_WORKAROUNDS +#ifdef WORKAROUND_GCC46_COMPILER // constexpr is buggy with templates in this version # define constexpr /* nothing */ #endif @@ -161,7 +161,7 @@ public: : const_array(a) {} }; -#ifdef ANNOYING_GCC46_WORKAROUNDS +#ifdef WORKAROUND_GCC46_COMPILER # undef constexpr #endif diff --git a/src/common/sanity.hpp b/src/common/sanity.hpp index e6f2807..8271ef8 100644 --- a/src/common/sanity.hpp +++ b/src/common/sanity.hpp @@ -4,11 +4,16 @@ # ifndef __cplusplus # error "Please compile in C++ mode" -# endif +# endif // __cplusplus # if __GNUC__ < 4 # error "Your compiler is absolutely ancient. You have no chance ..." -# endif +# endif // __GNUC__ < 4 + +/// Convert type assumptions to use the standard types here +# include +/// size_t, NULL +# include # if __GNUC__ == 4 // clang identifies as GCC 4.2, but is mostly okay. @@ -16,28 +21,40 @@ // (patched) clang 3.1 would be the requirement # if __GNUC_MINOR__ < 6 && !defined(__clang__) # error "Please upgrade to at least GCC 4.6" -# endif +# endif // __GNUC_MINOR__ < 6 && !defined(__clang__) +// temporary workaround for library issues +// since __GLIBCXX__ is hard to use # if __GNUC_MINOR__ == 6 -# define ANNOYING_GCC46_WORKAROUNDS -# endif -# endif +# define WORKAROUND_GCC46_COMPILER +# endif // __GNUC_MINOR__ == 6 +# ifdef __GLIBCXX__ +// versions of libstdc++ from gcc +// 4.6.0, 4.6.1, 4.6.2, 4.6.3 +# if __GLIBCXX__ == 20110325 \ + || __GLIBCXX__ == 20110627 \ + || __GLIBCXX__ == 20111026 \ + || __GLIBCXX__ == 20120301 \ + || __GLIBCXX__ == 20121127 // prerelease in Debian wheezy +# define WORKAROUND_GCC46_LIBRARY +# endif // __GLIBCXX__ == ... +# endif // defined __GLIBCXX__ +# if defined(WORKAROUND_GCC46_COMPILER) \ + && !defined(WORKAROUND_GCC46_LIBRARY) +# error "Unknown gcc 4.6.x release" +# endif // compiler and not library +# endif // __GNUC__ == 4 # ifndef __i386__ // Known platform dependencies: // endianness for the [RW]FIFO.* macros // possibly, some signal-handling # error "Unsupported platform" -# endif +# endif // not __i386__ # ifdef __x86_64__ // I'm working on it - I know there are some pointer-size assumptions. # error "Sorry, this code is believed not to be 64-bit safe" # error "please compile with -m32" -# endif - -/// Convert type assumptions to use the standard types here -# include -/// size_t, NULL -# include +# endif // __x86_64__ #endif // SANITY_HPP -- cgit v1.2.3-70-g09d2