From 6240e4458cdf5a17c7b795def33b81cb5a987aed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 30 Nov 2023 23:24:37 +0100 Subject: [PATCH] build: use -std=c99 and -std=c++11 by default MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Relying on the compiler default is problematic: * New constructs may be introduced accidentally that break backwards compatibility. * Older compilers may default to a more restricted standard than the codebase is actually developed with. Explicitly select C99 (and C++11 for the fuzzing part). Autotools does not want to default to C99, so set it explcitly during CI. Signed-off-by: Thomas Weißschuh --- .github/workflows/cibuild.sh | 4 ++-- meson.build | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cibuild.sh b/.github/workflows/cibuild.sh index bd77c053d7..be466daa25 100755 --- a/.github/workflows/cibuild.sh +++ b/.github/workflows/cibuild.sh @@ -5,8 +5,8 @@ set -ex PHASES=(${@:-CONFIGURE MAKE INSTALL CHECK DISTCHECK}) COMPILER="${COMPILER:?}" COMPILER_VERSION="${COMPILER_VERSION}" -CFLAGS=(-O1 -g) -CXXFLAGS=(-O1 -g) +CFLAGS=(-O1 -g -std=c99) +CXXFLAGS=(-O1 -g -std=c++11) LDFLAGS=() COVERITY_SCAN_TOOL_BASE="/tmp/coverity-scan-analysis" diff --git a/meson.build b/meson.build index fb2818a5d3..331d758298 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,11 @@ project('util-linux', 'c', version : run_command('tools/git-version-gen', check: true).stdout(), meson_version: '>=0.60.0', - license : 'GPLv2+') + license : 'GPLv2+', + default_options : [ + 'c_std=c99', + 'cpp_std=c++11', + ]) fs = import('fs') pkgconfig = import('pkgconfig') -- 2.47.3