Commit 09b93ccc by Dmitry Trifonov Committed by Eric

fix android compilation (#372)

* fix android compilation * checking __GLIBCXX__ and __GLIBCPP__ macro in addition to __ANDROID__ * using vsnprintf instead of std::vsnprintf to compile on Android * removed __GLIBCPP__ check on Android * StringPrintF instead of std::to_string for Android
parent 46afd8e6
......@@ -31,6 +31,7 @@
#include <fstream>
#include <iostream>
#include <memory>
#include <sstream>
#include <thread>
#include "check.h"
......@@ -163,8 +164,8 @@ bool BenchmarkFamilies::FindBenchmarks(
StringPrintF("%s:", family->arg_names_[arg_i].c_str());
}
}
instance.name += std::to_string(arg);
instance.name += StringPrintF("%d", arg);
++arg_i;
}
......
......@@ -89,7 +89,7 @@ std::string FormatString(const char* msg, va_list args) {
std::size_t size = 256;
char local_buff[256];
auto ret = std::vsnprintf(local_buff, size, msg, args_cp);
auto ret = vsnprintf(local_buff, size, msg, args_cp);
va_end(args_cp);
......@@ -104,7 +104,7 @@ std::string FormatString(const char* msg, va_list args) {
// we did not provide a long enough buffer on our first attempt.
size = (size_t)ret + 1; // + 1 for the null byte
std::unique_ptr<char[]> buff(new char[size]);
ret = std::vsnprintf(buff.get(), size, msg, args);
ret = vsnprintf(buff.get(), size, msg, args);
CHECK(ret > 0 && ((size_t)ret) < size);
return buff.get();
}
......
......@@ -114,14 +114,14 @@ void TestRegistrationAtRuntime() {
#endif
#ifndef BENCHMARK_HAS_NO_VARIADIC_REGISTER_BENCHMARK
{
int x = 42;
const char* x = "42";
auto capturing_lam = [=](benchmark::State& st) {
while (st.KeepRunning()) {
}
st.SetLabel(std::to_string(x));
st.SetLabel(x);
};
benchmark::RegisterBenchmark("lambda_benchmark", capturing_lam);
AddCases({{"lambda_benchmark", "42"}});
AddCases({{"lambda_benchmark", x}});
}
#endif
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment