From 624d6c0f97362059e0beed0abcccf8b9ff0dc49a Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 8 Jan 2026 01:45:45 +0900 Subject: feat: ignore all kinds of -std=* --- src/cli.c | 4 ++-- src/common.c | 8 ++++++++ src/common.h | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cli.c b/src/cli.c index cd5e1d9..7fe2119 100644 --- a/src/cli.c +++ b/src/cli.c @@ -61,8 +61,8 @@ CliArgs* parse_cli_args(int argc, char** argv) { } else if (strcmp(argv[i], "--version") == 0) { print_version(); exit(0); - } else if (strcmp(argv[i], "-std=gnu23") == 0) { - // ignore -std=gnu23 + } else if (str_starts_with(argv[i], "-std=")) { + // ignore -std=* } else if (strcmp(argv[i], "--wasm") == 0) { opt_wasm = true; } else { diff --git a/src/common.c b/src/common.c index 61b2805..af35064 100644 --- a/src/common.c +++ b/src/common.c @@ -13,6 +13,14 @@ void fatal_error(const char* msg, ...) { exit(1); } +bool str_starts_with(const char* s, const char* prefix) { + size_t l1 = strlen(s); + size_t l2 = strlen(prefix); + if (l1 < l2) + return false; + return strncmp(s, prefix, l2) == 0; +} + bool str_ends_with(const char* s, const char* suffix) { size_t l1 = strlen(s); size_t l2 = strlen(suffix); diff --git a/src/common.h b/src/common.h index b6fc238..bb94e79 100644 --- a/src/common.h +++ b/src/common.h @@ -12,6 +12,7 @@ _Noreturn void fatal_error(const char* msg, ...); #define unimplemented() fatal_error("%s:%d: unimplemented", __FILE__, __LINE__) +bool str_starts_with(const char* s, const char* prefix); bool str_ends_with(const char* s, const char* suffix); typedef struct { -- cgit v1.2.3-70-g09d2