From d5ce5329ea3ac8255d1cc1fa30c260bc0d534b77 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Sun, 26 Apr 2026 14:46:11 +0200 Subject: [PATCH] Fix compilation with GCC 9 --- Makefile | 3 ++- include/util.hpp | 4 ++-- src/asm/fixpoint.cpp | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 8f7f1ad9..81078c29 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,8 @@ WARNFLAGS := -Wall -pedantic -Wno-unknown-warning-option -Wno-gnu-zero-variadic- # Overridable CXXFLAGS CXXFLAGS ?= -O3 -flto -DNDEBUG # Non-overridable CXXFLAGS -REALCXXFLAGS := ${CXXFLAGS} ${WARNFLAGS} -std=c++20 -I include -fno-exceptions -fno-rtti +# GCC 9 doesn't support `-std=c++20`, and all later GCCs treat it as equivalent to `-std=c++2a`. +REALCXXFLAGS := ${CXXFLAGS} ${WARNFLAGS} -std=c++2a -I include -fno-exceptions -fno-rtti # Overridable LDFLAGS LDFLAGS ?= # Non-overridable LDFLAGS diff --git a/include/util.hpp b/include/util.hpp index 3d8b208a..7d025448 100644 --- a/include/util.hpp +++ b/include/util.hpp @@ -50,14 +50,14 @@ char const *printChar(int c); struct Uppercase { // FNV-1a hash of an uppercased string - constexpr size_t operator()(std::string const &str) const { + size_t operator()(std::string const &str) const { return std::accumulate(RANGE(str), size_t(0x811C9DC5), [](size_t hash, char c) { return (hash ^ toUpper(c)) * 16777619; }); } // Compare two strings without case-sensitivity (by converting to uppercase) - constexpr bool operator()(std::string const &str1, std::string const &str2) const { + bool operator()(std::string const &str1, std::string const &str2) const { return std::equal(RANGE(str1), RANGE(str2), [](char c1, char c2) { return toUpper(c1) == toUpper(c2); }); diff --git a/src/asm/fixpoint.cpp b/src/asm/fixpoint.cpp index d8097bac..c492eba3 100644 --- a/src/asm/fixpoint.cpp +++ b/src/asm/fixpoint.cpp @@ -5,10 +5,10 @@ #include "asm/fixpoint.hpp" #include -#include #include -static constexpr double tau = std::numbers::pi * 2; +// Ideally we'd use `std::numbers::pi`, but GCC 9 doesn't support it. +static constexpr double tau = 3.141592653589793238462643383279502884L * 2; static double fix2double(int32_t i, int32_t q) { return i / pow(2.0, q);