From 51326d59fc1054b2a1c33467130cae7e159f0983 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 15 Jul 2022 15:42:52 -0400 Subject: Define _POSIX_C_SOURCE globally in the build system Using inconsistent defines like this that affect the standard library implementation can cause issues. So, doing this consistently for the whole library is a better approach, although it unfortunately makes the code more difficult to compile manually. --- meson.build | 15 +++++++++++++-- src/.clang-tidy | 2 -- src/serdi.c | 2 -- src/system.c | 2 -- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 6a3ce355..f8d7f439 100644 --- a/meson.build +++ b/meson.build @@ -36,6 +36,17 @@ subdir('meson/suppressions') m_dep = cc.find_library('m', required: false) +########################## +# Platform Configuration # +########################## + +platform_args = [] +if host_machine.system() in ['gnu', 'linux'] + platform_args += [ + '-D_POSIX_C_SOURCE=200809L', + ] +endif + ########### # Library # ########### @@ -70,7 +81,7 @@ endif libserd = library( meson.project_name() + library_suffix, sources, - c_args: c_suppressions + extra_c_args + [ + c_args: c_suppressions + extra_c_args + platform_args + [ '-DSERD_INTERNAL', '-DSERD_VERSION="@0@"'.format(meson.project_version()), ], @@ -116,7 +127,7 @@ if not get_option('tools').disabled() serdi = executable( 'serdi', files('src/serdi.c'), - c_args: c_suppressions, + c_args: c_suppressions + platform_args, dependencies: serd_dep, install: true, link_args: tool_link_args, diff --git a/src/.clang-tidy b/src/.clang-tidy index 44d02929..b7fff31a 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -7,8 +7,6 @@ Checks: > -bugprone-easily-swappable-parameters, -bugprone-reserved-identifier, -bugprone-suspicious-string-compare, - -cert-dcl37-c, - -cert-dcl51-cpp, -cert-err33-c, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, -concurrency-mt-unsafe, diff --git a/src/serdi.c b/src/serdi.c index bbeffa2b..7f57dc5f 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -14,8 +14,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define _POSIX_C_SOURCE 200809L /* for fileno and posix_fadvise */ - #include "serd_config.h" #include "string_utils.h" diff --git a/src/system.c b/src/system.c index f706902d..c3e31912 100644 --- a/src/system.c +++ b/src/system.c @@ -14,8 +14,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define _POSIX_C_SOURCE 200809L /* for posix_memalign and posix_fadvise */ - #include "system.h" #include "serd_config.h" -- cgit v1.2.1