Skip to content

Commit 705fe1a

Browse files
author
Maxim Egorushkin
committed
Remove using C++17 features in example.cc and tests.cc.
1 parent 2ae6471 commit 705fe1a

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ cxxflags.gcc.debug := -Og -f{stack-protector-all,no-omit-frame-pointer} # -D_GLI
151151
cxxflags.gcc.release := -O3 -mtune=native -fno-{stack-protector,stack-clash-protection,move-loop-invariants} -falign-functions=64 -DNDEBUG ${cxxflags.gcc.asm.${ASM}}
152152
cxxflags.gcc.sanitize := ${cxxflags.gcc.debug} -fsanitize=thread
153153
cxxflags.gcc.sanitize2 := ${cxxflags.gcc.debug} -fsanitize=undefined,address
154-
cxxflags.gcc := -march=native -f{no-plt,no-math-errno,finite-math-only,message-length=0} -W{all,extra,error,no-maybe-uninitialized} ${cxxflags.gcc.${BUILD}}
154+
cxxflags.gcc := -march=native -f{no-plt,no-math-errno,finite-math-only,message-length=0} -W{all,extra,error,no-maybe-uninitialized,no-unused-variable} ${cxxflags.gcc.${BUILD}}
155155
ldflags.gcc.sanitize := ${ldflags.gcc.debug} -fsanitize=thread
156156
ldflags.gcc.sanitize2 := ${ldflags.gcc.debug} -fsanitize=undefined,address
157157
# ldflags.gcc := -fuse-ld=${use-ld.gcc} -Wl,--compress-debug-sections=zstd,-O2,--gc-sections ${ldflags.gcc.${BUILD}}
@@ -163,7 +163,7 @@ cxxflags.clang.debug := -O0 -fstack-protector-all $(and ${has_native},-march=nat
163163
cxxflags.clang.release := -O3 -fno-stack-protector -falign-functions=64 -DNDEBUG $(and ${has_native},-march=native -mtune=native)
164164
cxxflags.clang.sanitize := ${cxxflags.clang.debug} -fsanitize=thread
165165
cxxflags.clang.sanitize2 := ${cxxflags.clang.debug} -fsanitize=undefined,address
166-
cxxflags.clang := -stdlib=libstdc++ -f{no-plt,no-math-errno,finite-math-only,message-length=0} -W{all,extra,error} ${cxxflags.clang.${BUILD}}
166+
cxxflags.clang := -stdlib=libstdc++ -f{no-plt,no-math-errno,finite-math-only,message-length=0} -W{all,extra,error,no-unused-variable} ${cxxflags.clang.${BUILD}}
167167
ldflags.clang.debug := -latomic # A work-around for clang bug.
168168
ldflags.clang.sanitize := ${ldflags.clang.debug} -fsanitize=thread
169169
ldflags.clang.sanitize2 := ${ldflags.clang.debug} -fsanitize=undefined,address
@@ -208,7 +208,6 @@ endif
208208
exes := example tests benchmarks
209209

210210
example_src := example.cc
211-
${build_dir}/example.o : cxxflags += -std=c++17 # example.cc uses c++17 features.
212211

213212
tests_src := tests.cc
214213
${build_dir}/tests.o : cppflags += -DBOOST_TEST_DYN_LINK=1

meson.build

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,27 @@ threads_dep = dependency('threads')
1313
atomic_queue_dep = declare_dependency(include_directories : ['include'], dependencies : threads_dep)
1414

1515
if get_option('tests')
16+
cxx = meson.get_compiler('cpp')
17+
wno_unused_variable = []
18+
if cxx.get_id() == 'gcc' or cxx.get_id() == 'clang'
19+
wno_unused_variable = ['-Wno-unused-variable']
20+
endif
21+
1622
unit_test_framework_dep = dependency('boost', modules : ['unit_test_framework'])
1723

18-
# Tests still compile with C++14, but benchmarks and example require C++17.
1924
tests_exe = executable(
2025
'tests',
2126
'src/tests.cc',
27+
cpp_args : wno_unused_variable,
2228
dependencies : [atomic_queue_dep, unit_test_framework_dep],
2329
)
2430
test('tests', tests_exe)
2531

2632
example_exe = executable(
2733
'example',
2834
'src/example.cc',
35+
cpp_args : wno_unused_variable,
2936
dependencies : [atomic_queue_dep],
30-
cpp_args: ['-std=c++17']
3137
)
3238
test('example', example_exe)
3339
endif
@@ -50,7 +56,7 @@ if get_option('benchmarks')
5056
['src/benchmarks.cc', 'src/cpu_base_frequency.cc', 'src/huge_pages.cc'],
5157
include_directories : ['src'],
5258
dependencies : [atomic_queue_dep, dl_dep, xenium_dep, boost_dep, tbb_dep, moodycamel_dep],
53-
cpp_args: ['-std=c++17']
59+
override_options : ['cpp_std=c++17']
5460
)
5561
benchmark('benchmarks', benchmarks_exe)
5662
endif

src/example.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int main() {
5050
producer.join();
5151

5252
// Tell consumers to terminate by pushing one 0 element for each consumer.
53-
for([[maybe_unused]] auto& consumer : consumers)
53+
for(auto& consumer : consumers)
5454
q.push(0);
5555
// Wait till consumers have terminated.
5656
for(auto& consumer : consumers)

src/tests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(stress, Queue, stress_queues) {
7979

8080
for(auto& t : producers)
8181
t.join();
82-
for([[maybe_unused]] auto& consumer : consumers)
82+
for(auto& consumer : consumers)
8383
q.push(STOP_MSG);
8484
for(auto& t : consumers)
8585
t.join();

0 commit comments

Comments
 (0)