Fix two GCC 16 issues (#2164)
* [test] Mark unused variables
Found by GCC (-Wunused-but-set-variable).
* [utils] Add missing include for export macro
diff --git a/include/benchmark/utils.h b/include/benchmark/utils.h
index 2be0d3f..681d938 100644
--- a/include/benchmark/utils.h
+++ b/include/benchmark/utils.h
@@ -19,6 +19,7 @@
#include <type_traits>
#include <utility>
+#include "benchmark/export.h"
#include "benchmark/macros.h"
namespace benchmark {
diff --git a/test/basic_test.cc b/test/basic_test.cc
index e1db1cb..a20e5b4 100644
--- a/test/basic_test.cc
+++ b/test/basic_test.cc
@@ -1,4 +1,5 @@
+#include "benchmark/macros.h"
#include "benchmark/registration.h"
#include "benchmark/state.h"
#include "benchmark/types.h"
@@ -150,7 +151,7 @@
template <typename T>
void BM_OneTemplateFunc(benchmark::State& state) {
auto arg = state.range(0);
- T sum = 0;
+ BENCHMARK_UNUSED T sum = 0;
for (auto _ : state) {
sum += static_cast<T>(arg);
}
@@ -161,8 +162,8 @@
template <typename A, typename B>
void BM_TwoTemplateFunc(benchmark::State& state) {
auto arg = state.range(0);
- A sum = 0;
- B prod = 1;
+ BENCHMARK_UNUSED A sum = 0;
+ BENCHMARK_UNUSED B prod = 1;
for (auto _ : state) {
sum += static_cast<A>(arg);
prod *= static_cast<B>(arg);