Skip to content

Commit

Permalink
Avoid erroring on C++17 extensions under Clang
Browse files Browse the repository at this point in the history
google/googletest@5a37b517ad introduced a check on `__has_cpp_attribute(maybe_unused)`. Under Clang it evaluates to true even in `-std=c++14` mode, but subsequently the use of the `[[maybe_unused]]` attribute triggers a `-Wc++17-extensions` warning which we elevate to an error via `-pedantic-errors`.

This was observed in Termux and in the macOS Travis CI environment, where we use Apple Clang: https://app.travis-ci.com/github/tanzislam/cryptopals/jobs/625697125

Interestingly, attempting to downgrade that error back to a warning with `-Wno-error=c++17-extensions` did not work.

A similar Clang issue with a different C++17 attribute was also observed in nlohmann/json#1535.
  • Loading branch information
tanzislam committed Oct 12, 2024
1 parent 7960f36 commit a3797da
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common_settings.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ this_plugin := $(lastword $(MAKEFILE_LIST))
CXX = g++
CPP_STANDARD = -std=c++14 -pthread
CPP_QUALITY_CHECKS = -pedantic -pedantic-errors -Wall -Wextra
CPP_QUALITY_CHECKS += $(if $(filter clang,$(shell g++ --version)), \
-Wno-c++17-extensions)
CPP_OPTIMIZATIONS = -O3 -ffunction-sections -fdata-sections
CPPFLAGS = $(CPP_STANDARD) $(CPP_QUALITY_CHECKS) $(CPP_OPTIMIZATIONS)
CXXFLAGS := -isystem $(BOOST_DIR) \
Expand Down

0 comments on commit a3797da

Please sign in to comment.