From 5609e3778cc12d67e7ae8a851f0b5c2a3e47e058 Mon Sep 17 00:00:00 2001 From: minefreak19 <61090340+minefreak19@users.noreply.github.com> Date: Sat, 30 Aug 2025 19:10:43 +0530 Subject: [PATCH] Invert `NOB_STRIP_PREFIX` and `NOB_STRIP_PREFIX_GUARD_` checks This way, NOB_STRIP_PREFIX_GUARD_ is not defined until the prefixes are actually stripped, so a header file can simply `#include "nob.h"` without polluting the namespace while the corresponding C file can `#define NOB_STRIP_PREFIX` and re-include nob.h to use the short names. --- nob.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nob.h b/nob.h index 737f61f..9254fe1 100644 --- a/nob.h +++ b/nob.h @@ -2189,15 +2189,16 @@ NOBDEF int closedir(DIR *dirp) #endif // NOB_IMPLEMENTATION -#ifndef NOB_STRIP_PREFIX_GUARD_ -#define NOB_STRIP_PREFIX_GUARD_ +#ifdef NOB_STRIP_PREFIX // NOTE: The name stripping should be part of the header so it's not accidentally included // several times. At the same time, it should be at the end of the file so to not create any // potential conflicts in the NOB_IMPLEMENTATION. The header obviously cannot be at the end // of the file because NOB_IMPLEMENTATION needs the forward declarations from there. So the // solution is to split the header into two parts where the name stripping part is at the // end of the file after the NOB_IMPLEMENTATION. - #ifdef NOB_STRIP_PREFIX + #ifndef NOB_STRIP_PREFIX_GUARD_ + #define NOB_STRIP_PREFIX_GUARD_ + #define TODO NOB_TODO #define UNREACHABLE NOB_UNREACHABLE #define UNUSED NOB_UNUSED @@ -2304,8 +2305,8 @@ NOBDEF int closedir(DIR *dirp) #define nprocs nob_nprocs #define nanos_since_unspecified_epoch nob_nanos_since_unspecified_epoch #define NANOS_PER_SEC NOB_NANOS_PER_SEC - #endif // NOB_STRIP_PREFIX -#endif // NOB_STRIP_PREFIX_GUARD_ + #endif // NOB_STRIP_PREFIX_GUARD_ +#endif // NOB_STRIP_PREFIX /* Revision history: