From d4607eb8974a0fcd034ba6d93624544815788ff2 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Wed, 20 Apr 2016 17:29:00 -0700 Subject: Add includes for clang++/libc++ on Ubuntu There are a number of stdlib.h uses in these files without including stdlib.h: hash_collision_bench.cc: rand, RAND_MAX, srand manifest_parser_perftest.cc: system, exit ninja_test.cc: EXIT_SUCCESS, EXIT_FAILURE test.cc: getenv, mkdtemp, system This works on a Ubuntu g++/libstdc++ build, as the header pulls in stdlib.h, and on a OSX clang++/libc++ build the and headers pull in stdlib.h. But a Ubuntu clang++/libc++ build does not pull in stdlib.h with any of these other headers. $ apt-get install clang-3.6 libc++-dev $ CXX=clang++-3.6 CFLAGS=-stdlib=libc++ LDFLAGS=-stdlib=libc++ \ ./configure.py $ ninja ninja_test hash_collision_bench manifest_parser_perftest This was originally discovered using the host toolchain provided with Android, but the Ubuntu version is much easier to reproduce. --- src/hash_collision_bench.cc | 1 + src/manifest_parser_perftest.cc | 1 + src/ninja_test.cc | 1 + src/test.cc | 1 + 4 files changed, 4 insertions(+) diff --git a/src/hash_collision_bench.cc b/src/hash_collision_bench.cc index 5be0531..ff947dc 100644 --- a/src/hash_collision_bench.cc +++ b/src/hash_collision_bench.cc @@ -17,6 +17,7 @@ #include using namespace std; +#include #include int random(int low, int high) { diff --git a/src/manifest_parser_perftest.cc b/src/manifest_parser_perftest.cc index 572e2d5..60c2054 100644 --- a/src/manifest_parser_perftest.cc +++ b/src/manifest_parser_perftest.cc @@ -19,6 +19,7 @@ #include #include +#include #include #ifdef _WIN32 diff --git a/src/ninja_test.cc b/src/ninja_test.cc index 11087b6..d642c5c 100644 --- a/src/ninja_test.cc +++ b/src/ninja_test.cc @@ -14,6 +14,7 @@ #include #include +#include #ifdef _WIN32 #include "getopt.h" diff --git a/src/test.cc b/src/test.cc index 53bfc48..51882f0 100644 --- a/src/test.cc +++ b/src/test.cc @@ -21,6 +21,7 @@ #include #include +#include #ifdef _WIN32 #include #else -- cgit v0.12