Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated CMake and used [[maybe_unused]] if available. #168

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(fastor VERSION 0.6.4)
project(fastor VERSION 0.6.4 LANGUAGES CXX)

# specify the C++ standard
set(CMAKE_CXX_STANDARD 17)

option(BUILD_TESTING "Build the testing tree." ON)

Expand Down
14 changes: 13 additions & 1 deletion Fastor/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ SOFTWARE.
#define FASTOR_CXX_VERSION 2014
#elif __cplusplus == 201703L
#define FASTOR_CXX_VERSION 2017
#elif __cplusplus > 201703L
#elif __cplusplus > 202002L
#define FASTOR_CXX_VERSION 2020
#endif
#endif
Expand Down Expand Up @@ -163,6 +163,18 @@ SOFTWARE.
//------------------------------------------------------------------------------------------------//


// C++17 [[maybe_unused]] define
//------------------------------------------------------------------------------------------------//
#if FASTOR_CXX_VERSION >= 2017
#define FASTOR_MAYBE_UNUSED [[maybe_unused]]
#elif defined(__GNUC__) || defined(__clang__)
#define FASTOR_MAYBE_UNUSED [[gnu::unused]]
#elif defined(_MSC_VER)
#define FASTOR_MAYBE_UNUSED __declspec(maybe_unused)
#endif
//------------------------------------------------------------------------------------------------//



// Intrinsics defines
//------------------------------------------------------------------------------------------------//
Expand Down
4 changes: 2 additions & 2 deletions Fastor/util/extended_algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ inline size_t set_stack_size(size_t size) {

// Get sign of a number
template <typename T>
inline constexpr int signum(T x, [[gnu::unused]] std::false_type is_signed) {
inline constexpr int signum(T x, FASTOR_MAYBE_UNUSED std::false_type is_signed) {
return T(0) < x;
}
template <typename T>
inline constexpr int signum(T x, [[gnu::unused]] std::true_type is_signed) {
inline constexpr int signum(T x, FASTOR_MAYBE_UNUSED std::true_type is_signed) {
return (T(0) < x) - (x < T(0));
}
template <typename T>
Expand Down