From 942cb8a7c0861245ac0c734289d6ae7840bde080 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Thu, 3 Jul 2025 01:21:19 +0100 Subject: [PATCH 1/2] sd-common: do not fail preprocessor when intellisense is parsing the header Just like coverity or clang analyzer, intellisense will parse _sd-common.h and fail because of the #error so skip it like the others --- src/systemd/_sd-common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systemd/_sd-common.h b/src/systemd/_sd-common.h index bf2e20e201..715b3ca297 100644 --- a/src/systemd/_sd-common.h +++ b/src/systemd/_sd-common.h @@ -26,7 +26,7 @@ /* This is a private header; never even think of including this directly! */ -#if defined(__INCLUDE_LEVEL__) && __INCLUDE_LEVEL__ <= 1 && !defined(__COVERITY__) && !defined(__clang_analyzer__) +#if defined(__INCLUDE_LEVEL__) && __INCLUDE_LEVEL__ <= 1 && !defined(__COVERITY__) && !defined(__clang_analyzer__) && !defined(__INTELLISENSE__) # error "Do not include _sd-common.h directly; it is a private header." #endif From e01ca3afdb297fe879eaabd02901ad2a4b547d0c Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Thu, 3 Jul 2025 01:23:31 +0100 Subject: [PATCH 2/2] macro: EDG compiler frontends doesn't support enum types It declares STDC_VERSION 202311L but still doesn't support this feature: https://en.cppreference.com/w/c/compiler_support/23 The EDG frontend is used by intellisense, which is the default engine in VSCode, so parsing is currently broken and tons of spurious errors are shown. Skip this feature when this compiler frontend is used. Follow-up for 92100f14c3b054903053559ed831a1b25033046c --- src/fundamental/macro-fundamental.h | 2 +- src/systemd/_sd-common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index 69bbeead48..7a962df82a 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -472,7 +472,7 @@ assert_cc(STRLEN(__FILE__) > STRLEN(RELATIVE_SOURCE_PATH) + 1); #define PROJECT_FILE (&__FILE__[STRLEN(RELATIVE_SOURCE_PATH) + 1]) /* In GCC 14 (C23) we can force enums to have the right types, and not solely rely on language extensions anymore */ -#if __GNUC__ >= 14 || __STDC_VERSION__ >= 202311L +#if (__GNUC__ >= 14 || __STDC_VERSION__ >= 202311L) && !defined(__EDG__) # define ENUM_TYPE_S64(id) id : int64_t #else # define ENUM_TYPE_S64(id) id diff --git a/src/systemd/_sd-common.h b/src/systemd/_sd-common.h index 715b3ca297..1b855bfdd2 100644 --- a/src/systemd/_sd-common.h +++ b/src/systemd/_sd-common.h @@ -117,7 +117,7 @@ typedef void (*_sd_destroy_t)(void *userdata); _SD_##id##_INT64_MAX = INT64_MAX /* In GCC 14 (C23) we can force enums to have the right types, and not solely rely on language extensions anymore */ -#if ((__GNUC__ >= 14) || (__STDC_VERSION__ >= 202311L)) && !defined(__cplusplus) +#if ((__GNUC__ >= 14) || (__STDC_VERSION__ >= 202311L)) && !defined(__cplusplus) && !defined(__EDG__) # define _SD_ENUM_TYPE_S64(id) id : int64_t #else # define _SD_ENUM_TYPE_S64(id) id