Skip to content

Commit a92a6f7

Browse files
author
vladlosev
committed
Fixed Native Client build of gtest when using glibc (by Ben Smith).
git-svn-id: http://googletest.googlecode.com/svn/trunk@621 861a406c-534a-0410-8894-cb66d6ee9925
1 parent 11c6ddf commit a92a6f7

File tree

2 files changed

+55
-16
lines changed

2 files changed

+55
-16
lines changed

include/gtest/internal/gtest-port.h

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
// Test's own tr1 tuple implementation should be
7373
// used. Unused when the user sets
7474
// GTEST_HAS_TR1_TUPLE to 0.
75+
// GTEST_LANG_CXX11 - Define it to 1/0 to indicate that Google Test
76+
// is building in C++11/C++98 mode.
7577
// GTEST_LINKED_AS_SHARED_LIBRARY
7678
// - Define to 1 when compiling tests that use
7779
// Google Test as a shared library (known as
@@ -259,6 +261,19 @@
259261
# define GTEST_OS_QNX 1
260262
#endif // __CYGWIN__
261263

264+
#ifndef GTEST_LANG_CXX11
265+
// gcc and clang define __GXX_EXPERIMENTAL_CXX0X__ when
266+
// -std={c,gnu}++{0x,11} is passed. The C++11 standard specifies a
267+
// value for __cplusplus, and recent versions of clang, gcc, and
268+
// probably other compilers set that too in C++11 mode.
269+
# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L
270+
// Compiling in at least C++11 mode.
271+
# define GTEST_LANG_CXX11 1
272+
# else
273+
# define GTEST_LANG_CXX11 0
274+
# endif
275+
#endif
276+
262277
// Brings in definitions for functions used in the testing::internal::posix
263278
// namespace (read, write, close, chdir, isatty, stat). We do not currently
264279
// use them on Windows Mobile.
@@ -267,12 +282,7 @@
267282
// is not the case, we need to include headers that provide the functions
268283
// mentioned above.
269284
# include <unistd.h>
270-
# if !GTEST_OS_NACL
271-
// TODO([email protected]): Remove this condition when Native Client SDK adds
272-
// strings.h (tracked in
273-
// http://code.google.com/p/nativeclient/issues/detail?id=1175).
274-
# include <strings.h> // Native Client doesn't provide strings.h.
275-
# endif
285+
# include <strings.h>
276286
#elif !GTEST_OS_WINDOWS_MOBILE
277287
# include <direct.h>
278288
# include <io.h>
@@ -466,15 +476,28 @@
466476
// The user didn't tell us, so we need to figure it out.
467477

468478
// We use our own TR1 tuple if we aren't sure the user has an
469-
// implementation of it already. At this time, GCC 4.0.0+ and MSVC
470-
// 2010 are the only mainstream compilers that come with a TR1 tuple
471-
// implementation. NVIDIA's CUDA NVCC compiler pretends to be GCC by
472-
// defining __GNUC__ and friends, but cannot compile GCC's tuple
473-
// implementation. MSVC 2008 (9.0) provides TR1 tuple in a 323 MB
474-
// Feature Pack download, which we cannot assume the user has.
475-
// QNX's QCC compiler is a modified GCC but it doesn't support TR1 tuple.
479+
// implementation of it already. At this time, libstdc++ 4.0.0+ and
480+
// MSVC 2010 are the only mainstream standard libraries that come
481+
// with a TR1 tuple implementation. NVIDIA's CUDA NVCC compiler
482+
// pretends to be GCC by defining __GNUC__ and friends, but cannot
483+
// compile GCC's tuple implementation. MSVC 2008 (9.0) provides TR1
484+
// tuple in a 323 MB Feature Pack download, which we cannot assume the
485+
// user has. QNX's QCC compiler is a modified GCC but it doesn't
486+
// support TR1 tuple. libc++ only provides std::tuple, in C++11 mode,
487+
// and it can be used with some compilers that define __GNUC__.
476488
# if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \
477-
&& !GTEST_OS_QNX) || _MSC_VER >= 1600
489+
&& !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) || _MSC_VER >= 1600
490+
# define GTEST_ENV_HAS_TR1_TUPLE_ 1
491+
# endif
492+
493+
// C++11 specifies that <tuple> provides std::tuple. Users can't use
494+
// gtest in C++11 mode until their standard library is at least that
495+
// compliant.
496+
# if GTEST_LANG_CXX11
497+
# define GTEST_ENV_HAS_STD_TUPLE_ 1
498+
# endif
499+
500+
# if GTEST_ENV_HAS_TR1_TUPLE_ || GTEST_ENV_HAS_STD_TUPLE_
478501
# define GTEST_USE_OWN_TR1_TUPLE 0
479502
# else
480503
# define GTEST_USE_OWN_TR1_TUPLE 1
@@ -489,6 +512,22 @@
489512

490513
# if GTEST_USE_OWN_TR1_TUPLE
491514
# include "gtest/internal/gtest-tuple.h"
515+
# elif GTEST_ENV_HAS_STD_TUPLE_
516+
# include <tuple>
517+
// C++11 puts its tuple into the ::std namespace rather than
518+
// ::std::tr1. gtest expects tuple to live in ::std::tr1, so put it there.
519+
// This causes undefined behavior, but supported compilers react in
520+
// the way we intend.
521+
namespace std {
522+
namespace tr1 {
523+
using ::std::get;
524+
using ::std::make_tuple;
525+
using ::std::tuple;
526+
using ::std::tuple_element;
527+
using ::std::tuple_size;
528+
}
529+
}
530+
492531
# elif GTEST_OS_SYMBIAN
493532

494533
// On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to

src/gtest-filepath.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
#elif GTEST_OS_WINDOWS
4040
# include <direct.h>
4141
# include <io.h>
42-
#elif GTEST_OS_SYMBIAN || GTEST_OS_NACL
43-
// Symbian OpenC and NaCl have PATH_MAX in sys/syslimits.h
42+
#elif GTEST_OS_SYMBIAN
43+
// Symbian OpenC has PATH_MAX in sys/syslimits.h
4444
# include <sys/syslimits.h>
4545
#else
4646
# include <limits.h>

0 commit comments

Comments
 (0)