Skip to content

Commit 5609e37

Browse files
committed
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.
1 parent 8ddbc72 commit 5609e37

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

nob.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,15 +2189,16 @@ NOBDEF int closedir(DIR *dirp)
21892189

21902190
#endif // NOB_IMPLEMENTATION
21912191

2192-
#ifndef NOB_STRIP_PREFIX_GUARD_
2193-
#define NOB_STRIP_PREFIX_GUARD_
2192+
#ifdef NOB_STRIP_PREFIX
21942193
// NOTE: The name stripping should be part of the header so it's not accidentally included
21952194
// several times. At the same time, it should be at the end of the file so to not create any
21962195
// potential conflicts in the NOB_IMPLEMENTATION. The header obviously cannot be at the end
21972196
// of the file because NOB_IMPLEMENTATION needs the forward declarations from there. So the
21982197
// solution is to split the header into two parts where the name stripping part is at the
21992198
// end of the file after the NOB_IMPLEMENTATION.
2200-
#ifdef NOB_STRIP_PREFIX
2199+
#ifndef NOB_STRIP_PREFIX_GUARD_
2200+
#define NOB_STRIP_PREFIX_GUARD_
2201+
22012202
#define TODO NOB_TODO
22022203
#define UNREACHABLE NOB_UNREACHABLE
22032204
#define UNUSED NOB_UNUSED
@@ -2304,8 +2305,8 @@ NOBDEF int closedir(DIR *dirp)
23042305
#define nprocs nob_nprocs
23052306
#define nanos_since_unspecified_epoch nob_nanos_since_unspecified_epoch
23062307
#define NANOS_PER_SEC NOB_NANOS_PER_SEC
2307-
#endif // NOB_STRIP_PREFIX
2308-
#endif // NOB_STRIP_PREFIX_GUARD_
2308+
#endif // NOB_STRIP_PREFIX_GUARD_
2309+
#endif // NOB_STRIP_PREFIX
23092310

23102311
/*
23112312
Revision history:

0 commit comments

Comments
 (0)