[tlbuild] interact.cc and getline insanity

Mojca Miklavec mojca.miklavec.lists at gmail.com
Fri Apr 25 17:58:50 CEST 2014


> Does gcc under Solaris not define __GNUC_PREREQ? In any case, I'll change
> this so that if GNUC_PREREQ is not defined unordered_map will be used by
> default.

These are all the defines containing GNU that I see (when using gcc 4.8):

#define __GNUC_PATCHLEVEL__ 2
#define __GNUC__ 4
#define __GNUC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 +
__GNUC_PATCHLEVEL__)
#define __GNUC_VA_LIST
#define __GNUC_MINOR__ 8
#define __GNUC_GNU_INLINE__ 1

I'm not sure how to test for sure that GNUC_PREREQ isn't defined.

With clang on Mac OS X 10.7 I get:

#define __GNUC_MINOR__ 2
#define __GNUC_PATCHLEVEL__ 1
#define __GNUC_STDC_INLINE__ 1
#define __GNUC__ 4

Even with clang 3.4.

If I test the following on Mac (with clang):

#if __GNUC_PREREQ(4,1)
  printf("yes\n");
#else
  printf("no\n");
#endif

I get a compiler error:

error: token is not a valid binary operator in a preprocessor subexpression
#if __GNUC_PREREQ(4,1)

I believe that a different test is needed, but I'm not sure which one.

Blindly using "tr1" won't do any good either. Here's an example of the
code that I recently had to patch to make the compilation succeed on
multiple version of OS X (C++11 shouldn't use "tr1"):

#include <ciso646>

#if __cplusplus >= 201103L || defined(_LIBCPP_VERSION)
#include <memory>
#else
#include <tr1/memory>
#endif

#if __cplusplus >= 201103L || defined(_LIBCPP_VERSION)
using std::shared_ptr;
using std::static_pointer_cast;
using std::weak_ptr;
#else
using std::tr1::shared_ptr;
using std::tr1::static_pointer_cast;
using std::tr1::weak_ptr;
#endif

Mojca



More information about the tlbuild mailing list