Enable zero as NULL warnings and fix all occurences
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4296b23..4255dc7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,8 +38,7 @@
add_cxx_compiler_flag(-Wshadow)
add_cxx_compiler_flag(-Werror)
add_cxx_compiler_flag(-pedantic-errors)
-# TODO(ericwf): enable this for g++
-#add_cxx_compiler_flag(-Wzero-as-null-pointer-constant)
+add_cxx_compiler_flag(-Wzero-as-null-pointer-constant)
# Release flags
add_cxx_compiler_flag(-fno-strict-aliasing RELEASE)
diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h
index aa80bbc..f796dc3 100644
--- a/include/benchmark/benchmark.h
+++ b/include/benchmark/benchmark.h
@@ -152,7 +152,8 @@
// Otherwise, run all benchmarks specified by the --benchmark_filter flag,
// and exit after running the benchmarks.
-void RunSpecifiedBenchmarks(const BenchmarkReporter* reporter = NULL);
+void RunSpecifiedBenchmarks();
+void RunSpecifiedBenchmarks(const BenchmarkReporter* reporter);
// If this routine is called, peak memory allocation past this point in the
// benchmark is reported at the end of the benchmark report line. (It is
@@ -164,6 +165,19 @@
namespace internal {
class Benchmark;
class BenchmarkFamilies;
+
+template <class T> struct Voider {
+ typedef void type;
+};
+
+template <class T, class = void>
+struct EnableIfString {};
+
+template <class T>
+struct EnableIfString<T, typename Voider<typename T::basic_string>::type> {
+ typedef int type;
+};
+
}
// State is passed to a running Benchmark and contains state for the
@@ -279,7 +293,7 @@
// as an injected class name in the case of std::string.
template <class StringType>
void SetLabel(StringType const & str,
- typename StringType::basic_string* = 0) {
+ typename internal::EnableIfString<StringType>::type = 1) {
this->SetLabel(str.c_str());
}
diff --git a/src/benchmark.cc b/src/benchmark.cc
index 8b0682e..82f5f5f 100644
--- a/src/benchmark.cc
+++ b/src/benchmark.cc
@@ -898,6 +898,9 @@
} // end namespace internal
+void RunSpecifiedBenchmarks() {
+ RunSpecifiedBenchmarks(nullptr);
+}
void RunSpecifiedBenchmarks(const BenchmarkReporter* reporter) {
std::string spec = FLAGS_benchmark_filter;
diff --git a/src/sysinfo.cc b/src/sysinfo.cc
index ace7caa..b275360 100644
--- a/src/sysinfo.cc
+++ b/src/sysinfo.cc
@@ -303,7 +303,7 @@
cputime_fd = -1;
return false;
}
- unsigned long long result = strtoull(buff, NULL, 0);
+ unsigned long long result = strtoull(buff, nullptr, 0);
if (result == (std::numeric_limits<unsigned long long>::max)()) {
close(cputime_fd);
cputime_fd = -1;
diff --git a/src/walltime.cc b/src/walltime.cc
index 39c0497..fa1b61f 100644
--- a/src/walltime.cc
+++ b/src/walltime.cc
@@ -89,7 +89,7 @@
WallTime Slow() const {
struct timeval tv;
- gettimeofday(&tv, NULL);
+ gettimeofday(&tv, nullptr);
return tv.tv_sec + tv.tv_usec * 1e-6;
}