|
1 | | -/* nob - v3.9.0 - Public Domain - https://github.com/tsoding/nob.h |
| 1 | +/* nob - v3.10.0 - Public Domain - https://github.com/tsoding/nob.h |
2 | 2 |
|
3 | 3 | This library is the next generation of the [NoBuild](https://github.com/tsoding/nobuild) idea. |
4 | 4 |
|
@@ -947,7 +947,11 @@ NOBDEF Nob_String_View nob_sv_from_parts(const char *data, size_t count); |
947 | 947 | // nob_sb_to_sv() enables you to just view Nob_String_Builder as Nob_String_View |
948 | 948 | #define nob_sb_to_sv(sb) nob_sv_from_parts((sb).items, (sb).count) |
949 | 949 |
|
950 | | -#define NOB_SVLIT(lit) nob_sv_from_parts((lit), sizeof(lit)-1) |
| 950 | +#define NOB_SVLIT(lit) (NOB_CLIT(Nob_String_View){.count = sizeof(lit)-1, .data = (lit)}) |
| 951 | +// Generally majority of the C/C++ compilers will allow you to use NOB_SVLIT to construct global variables. |
| 952 | +// But there are some (specifically MSVC with /TC flag enabled) that will refuse. |
| 953 | +// For such compilers use NOB_SVLIT_STATIC instead. |
| 954 | +#define NOB_SVLIT_STATIC(lit) {.count = sizeof(lit)-1, .data = (lit)} |
951 | 955 |
|
952 | 956 | // printf macros for String_View |
953 | 957 | #ifndef SV_Fmt |
@@ -2956,6 +2960,7 @@ NOBDEF char *nob_temp_running_executable_path(void) |
2956 | 2960 | #define UNREACHABLE NOB_UNREACHABLE |
2957 | 2961 | #define UNREACHABLEF NOB_UNREACHABLEF |
2958 | 2962 | #define SVLIT NOB_SVLIT |
| 2963 | + #define SVLIT_STATIC NOB_SVLIT_STATIC |
2959 | 2964 | #define UNUSED NOB_UNUSED |
2960 | 2965 | #define ARRAY_LEN NOB_ARRAY_LEN |
2961 | 2966 | #define ARRAY_GET NOB_ARRAY_GET |
@@ -3125,6 +3130,8 @@ NOBDEF char *nob_temp_running_executable_path(void) |
3125 | 3130 | /* |
3126 | 3131 | Revision history: |
3127 | 3132 |
|
| 3133 | + 3.10.0 (2026-07-17) Make NOB_SVLIT a bit more usable at compile-time (by @Arhcout) |
| 3134 | + Add NOB_SVLIT_STATIC for when a compiler simply refuses to accept NOB_SVLIT() at compile-time (looking at you `cl.exe /TC`) (by @rexim) |
3128 | 3135 | 3.9.0 (2026-07-15) Add NOB_TODOF() and NOB_UNREACHABLEF() |
3129 | 3136 | Add NOB_SVLIT() |
3130 | 3137 | Add nob_bytes_for_utf8[] and nob_sv_utf8_len() |
|
0 commit comments