diff --git a/core/core.h b/core/core.h index c4c6e09..adddc42 100644 --- a/core/core.h +++ b/core/core.h @@ -1,4 +1,6 @@ -#pragma once +#ifndef FIRST_CORE_HEADER +#define FIRST_CORE_HEADER + #include "../standalone_libraries/preproc_env.h" #include "../standalone_libraries/stb_sprintf.h" #include "../standalone_libraries/io.h" @@ -29,3 +31,5 @@ if (!allocator.p) allocator = M_GetSystemAllocator(); #include "../standalone_libraries/array.hpp" #endif + +#endif \ No newline at end of file diff --git a/standalone_libraries/array.hpp b/standalone_libraries/array.hpp index a7e35dd..8907dd6 100644 --- a/standalone_libraries/array.hpp +++ b/standalone_libraries/array.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef FIRST_ARRAY_HEADER +#define FIRST_ARRAY_HEADER #ifndef ARRAY_REALLOCATE #include @@ -33,7 +34,7 @@ // if (it == 4) ForArrayRemovableDeclare(); // } // -#ifdef DEFER_HEADER +#ifdef FIRST_DEFER_HEADER #define ForArrayRemovable(a) for (int __i = 0; __i < (a).len; __i += 1) #define ForArrayRemovablePrepare(a) \ auto &it = (a)[__i]; \ @@ -48,7 +49,7 @@ #endif #ifndef For - #define For2(it, array) for(auto &it : (array)) + #define For2(it, array) for (auto &it : (array)) #define For(array) For2(it, array) #endif @@ -301,3 +302,5 @@ struct Array { } } }; + +#endif \ No newline at end of file diff --git a/standalone_libraries/clexer.h b/standalone_libraries/clexer.h index db523ac..47179ee 100644 --- a/standalone_libraries/clexer.h +++ b/standalone_libraries/clexer.h @@ -1,4 +1,6 @@ -#pragma once +#ifndef FIRST_CL_HEADER +#define FIRST_CL_HEADER + #include #include #include @@ -296,3 +298,5 @@ CL_INLINE bool CL_IsKeywordOrIdent(CL_Kind kind) { bool result = CL_IsKeyword(kind) || kind == CL_IDENTIFIER; return result; } + +#endif \ No newline at end of file diff --git a/standalone_libraries/defer.hpp b/standalone_libraries/defer.hpp index 29ccf1a..463ec4a 100644 --- a/standalone_libraries/defer.hpp +++ b/standalone_libraries/defer.hpp @@ -1,5 +1,5 @@ -#pragma once -#define DEFER_HEADER +#ifndef FIRST_DEFER_HEADER +#define FIRST_DEFER_HEADER template struct DEFER_ExitScope { @@ -20,4 +20,6 @@ class DEFER_ExitScopeHelp { #define DEFER_CONCAT_INTERNAL(x, y) x##y #define DEFER_CONCAT(x, y) DEFER_CONCAT_INTERNAL(x, y) -#define defer const auto DEFER_CONCAT(defer__, __LINE__) = DEFER_ExitScopeHelp() + [&]() \ No newline at end of file +#define defer const auto DEFER_CONCAT(defer__, __LINE__) = DEFER_ExitScopeHelp() + [&]() + +#endif \ No newline at end of file diff --git a/standalone_libraries/hash.h b/standalone_libraries/hash.h index cf442c5..073a9d2 100644 --- a/standalone_libraries/hash.h +++ b/standalone_libraries/hash.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FIRST_HASH_HEADER +#define FIRST_HASH_HEADER #include #ifndef HASH_API_FUNCTION @@ -24,3 +25,4 @@ HASH_API_FUNCTION uint64_t HashMix(uint64_t x, uint64_t y); #define WRAP_AROUND_POWER_OF_2(x, pow2) (((x) & ((pow2)-1llu))) static inline float GetRandomNormalF(RandomSeed *series) { return (float)GetRandomNormal(series); } +#endif \ No newline at end of file diff --git a/standalone_libraries/io.h b/standalone_libraries/io.h index 29a34b9..99ae5fc 100644 --- a/standalone_libraries/io.h +++ b/standalone_libraries/io.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FIRST_IO_HEADER +#define FIRST_IO_HEADER #include #ifndef IO_API @@ -86,4 +87,5 @@ const int IO_KindPrintf = 1; const int IO_KindWarningf = 2; #define IO_Printf(...) IO__Printf(IO_KindPrintf, __FILE__, __LINE__, __VA_ARGS__) -#define IO_Warningf(...) IO__Printf(IO_KindWarningf, __FILE__, __LINE__, __VA_ARGS__) \ No newline at end of file +#define IO_Warningf(...) IO__Printf(IO_KindWarningf, __FILE__, __LINE__, __VA_ARGS__) +#endif \ No newline at end of file diff --git a/standalone_libraries/linked_list.h b/standalone_libraries/linked_list.h index 693ff98..54a1a0f 100644 --- a/standalone_libraries/linked_list.h +++ b/standalone_libraries/linked_list.h @@ -1,125 +1,127 @@ -#pragma once -#define SLL_QUEUE_ADD_MOD(f, l, n, next) \ - do { \ - (n)->next = 0; \ - if ((f) == 0) { \ - (f) = (l) = (n); \ - } \ - else { \ - (l) = (l)->next = (n); \ - } \ - } while (0) -#define SLL_QUEUE_ADD(f, l, n) SLL_QUEUE_ADD_MOD(f, l, n, next) - -#define SLL_QUEUE_POP_FIRST_MOD(f, l, next) \ - do { \ - if ((f) == (l)) { \ - (f) = (l) = 0; \ - } \ - else { \ - (f) = (f)->next; \ - } \ - } while (0) -#define SLL_QUEUE_POP_FIRST(f, l) SLL_QUEUE_POP_FIRST_MOD(f, l, next) - -#define SLL_STACK_ADD_MOD(stack_base, new_stack_base, next) \ - do { \ - (new_stack_base)->next = (stack_base); \ - (stack_base) = (new_stack_base); \ - } while (0) -#define SLL_STACK_ADD(stack_base, new_stack_base) \ - SLL_STACK_ADD_MOD(stack_base, new_stack_base, next) - -#define SLL_STACK_POP_AND_STORE(stack_base, out_node) \ - do { \ - if (stack_base) { \ - (out_node) = (stack_base); \ - (stack_base) = (stack_base)->next; \ - (out_node)->next = 0; \ - } \ - } while (0) - -#define DLL_QUEUE_ADD_MOD(f, l, node, next, prev) \ - do { \ - if ((f) == 0) { \ - (f) = (l) = (node); \ - (node)->prev = 0; \ - (node)->next = 0; \ - } \ - else { \ - (l)->next = (node); \ - (node)->prev = (l); \ - (node)->next = 0; \ - (l) = (node); \ - } \ - } while (0) -#define DLL_QUEUE_ADD(f, l, node) DLL_QUEUE_ADD_MOD(f, l, node, next, prev) -#define DLL_QUEUE_REMOVE_MOD(first, last, node, next, prev) \ - do { \ - if ((first) == (last)) { \ - IO_Assertf((node) == (first), "Not you are trying to remove is not in the list"); \ - (first) = (last) = 0; \ - } \ - else if ((last) == (node)) { \ - (last) = (last)->prev; \ - (last)->next = 0; \ - } \ - else if ((first) == (node)) { \ - (first) = (first)->next; \ - (first)->prev = 0; \ - } \ - else { \ - (node)->prev->next = (node)->next; \ - (node)->next->prev = (node)->prev; \ - } \ - if (node) { \ - (node)->prev = 0; \ - (node)->next = 0; \ - } \ - } while (0) -#define DLL_QUEUE_REMOVE(first, last, node) DLL_QUEUE_REMOVE_MOD(first, last, node, next, prev) - -#define DLL_STACK_ADD_MOD(first, node, next, prev) \ - do { \ - (node)->next = (first); \ - if ((first)) \ - (first)->prev = (node); \ - (first) = (node); \ - (node)->prev = 0; \ - } while (0) -#define DLL_STACK_ADD(first, node) DLL_STACK_ADD_MOD(first, node, next, prev) -#define DLL_STACK_REMOVE_MOD(first, node, next, prev) \ - do { \ - if ((node) == (first)) { \ - (first) = (first)->next; \ - if ((first)) \ - (first)->prev = 0; \ - } \ - else { \ - (node)->prev->next = (node)->next; \ - if ((node)->next) \ - (node)->next->prev = (node)->prev; \ - } \ - if (node) { \ - (node)->prev = 0; \ - (node)->next = 0; \ - } \ - } while (0) -#define DLL_STACK_REMOVE(first, node) DLL_STACK_REMOVE_MOD(first, node, next, prev) - -#define DLL_INSERT_NEXT_MOD(base, new, next, prev) \ - do { \ - if ((base) == 0) { \ - (base) = (new); \ - (new)->next = 0; \ - (new)->prev = 0; \ - } \ - else { \ - (new)->next = (base)->next; \ - (base)->next = (new); \ - (new)->prev = (base); \ - if ((new)->next) (new)->next->prev = (new); \ - } \ - } while (0) -#define DLL_INSERT_NEXT(base, new) DLL_INSERT_NEXT_MOD(base, new, next, prev) -#define DLL_INSERT_PREV(base, new) DLL_INSERT_NEXT_MOD(base, new, next, prev) +#ifndef FIRST_LL_HEADER +#define FIRST_LL_HEADER +#define SLL_QUEUE_ADD_MOD(f, l, n, next) \ + do { \ + (n)->next = 0; \ + if ((f) == 0) { \ + (f) = (l) = (n); \ + } \ + else { \ + (l) = (l)->next = (n); \ + } \ + } while (0) +#define SLL_QUEUE_ADD(f, l, n) SLL_QUEUE_ADD_MOD(f, l, n, next) + +#define SLL_QUEUE_POP_FIRST_MOD(f, l, next) \ + do { \ + if ((f) == (l)) { \ + (f) = (l) = 0; \ + } \ + else { \ + (f) = (f)->next; \ + } \ + } while (0) +#define SLL_QUEUE_POP_FIRST(f, l) SLL_QUEUE_POP_FIRST_MOD(f, l, next) + +#define SLL_STACK_ADD_MOD(stack_base, new_stack_base, next) \ + do { \ + (new_stack_base)->next = (stack_base); \ + (stack_base) = (new_stack_base); \ + } while (0) +#define SLL_STACK_ADD(stack_base, new_stack_base) \ + SLL_STACK_ADD_MOD(stack_base, new_stack_base, next) + +#define SLL_STACK_POP_AND_STORE(stack_base, out_node) \ + do { \ + if (stack_base) { \ + (out_node) = (stack_base); \ + (stack_base) = (stack_base)->next; \ + (out_node)->next = 0; \ + } \ + } while (0) + +#define DLL_QUEUE_ADD_MOD(f, l, node, next, prev) \ + do { \ + if ((f) == 0) { \ + (f) = (l) = (node); \ + (node)->prev = 0; \ + (node)->next = 0; \ + } \ + else { \ + (l)->next = (node); \ + (node)->prev = (l); \ + (node)->next = 0; \ + (l) = (node); \ + } \ + } while (0) +#define DLL_QUEUE_ADD(f, l, node) DLL_QUEUE_ADD_MOD(f, l, node, next, prev) +#define DLL_QUEUE_REMOVE_MOD(first, last, node, next, prev) \ + do { \ + if ((first) == (last)) { \ + IO_Assertf((node) == (first), "Not you are trying to remove is not in the list"); \ + (first) = (last) = 0; \ + } \ + else if ((last) == (node)) { \ + (last) = (last)->prev; \ + (last)->next = 0; \ + } \ + else if ((first) == (node)) { \ + (first) = (first)->next; \ + (first)->prev = 0; \ + } \ + else { \ + (node)->prev->next = (node)->next; \ + (node)->next->prev = (node)->prev; \ + } \ + if (node) { \ + (node)->prev = 0; \ + (node)->next = 0; \ + } \ + } while (0) +#define DLL_QUEUE_REMOVE(first, last, node) DLL_QUEUE_REMOVE_MOD(first, last, node, next, prev) + +#define DLL_STACK_ADD_MOD(first, node, next, prev) \ + do { \ + (node)->next = (first); \ + if ((first)) \ + (first)->prev = (node); \ + (first) = (node); \ + (node)->prev = 0; \ + } while (0) +#define DLL_STACK_ADD(first, node) DLL_STACK_ADD_MOD(first, node, next, prev) +#define DLL_STACK_REMOVE_MOD(first, node, next, prev) \ + do { \ + if ((node) == (first)) { \ + (first) = (first)->next; \ + if ((first)) \ + (first)->prev = 0; \ + } \ + else { \ + (node)->prev->next = (node)->next; \ + if ((node)->next) \ + (node)->next->prev = (node)->prev; \ + } \ + if (node) { \ + (node)->prev = 0; \ + (node)->next = 0; \ + } \ + } while (0) +#define DLL_STACK_REMOVE(first, node) DLL_STACK_REMOVE_MOD(first, node, next, prev) + +#define DLL_INSERT_NEXT_MOD(base, new, next, prev) \ + do { \ + if ((base) == 0) { \ + (base) = (new); \ + (new)->next = 0; \ + (new)->prev = 0; \ + } \ + else { \ + (new)->next = (base)->next; \ + (base)->next = (new); \ + (new)->prev = (base); \ + if ((new)->next) (new)->next->prev = (new); \ + } \ + } while (0) +#define DLL_INSERT_NEXT(base, new) DLL_INSERT_NEXT_MOD(base, new, next, prev) +#define DLL_INSERT_PREV(base, new) DLL_INSERT_NEXT_MOD(base, new, next, prev) +#endif \ No newline at end of file diff --git a/standalone_libraries/load_library.h b/standalone_libraries/load_library.h index 327d4f8..3c98bbd 100644 --- a/standalone_libraries/load_library.h +++ b/standalone_libraries/load_library.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FIRST_LIB_HEADER +#define FIRST_LIB_HEADER typedef void *LIB_Library; LIB_Library LIB_LoadLibrary(char *str); @@ -8,3 +9,4 @@ bool LIB_UnloadLibrary(LIB_Library lib); #ifndef LIB_EXPORT #define LIB_EXPORT __declspec(dllexport) #endif +#endif \ No newline at end of file diff --git a/standalone_libraries/multimedia.h b/standalone_libraries/multimedia.h index ad69d95..241bf09 100644 --- a/standalone_libraries/multimedia.h +++ b/standalone_libraries/multimedia.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FIRST_MU_HEADER +#define FIRST_MU_HEADER #include #include #include @@ -366,3 +367,4 @@ typedef struct MU_Event { */ +#endif \ No newline at end of file diff --git a/standalone_libraries/preproc_env.h b/standalone_libraries/preproc_env.h index 8a0b434..8294033 100644 --- a/standalone_libraries/preproc_env.h +++ b/standalone_libraries/preproc_env.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FIRST_ENV_HEADER +#define FIRST_ENV_HEADER #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS #endif @@ -116,3 +117,4 @@ // #pragma clang diagnostic push // #pragma clang diagnostic ignored "-Wmicrosoft-enum-forward-reference" // #endif +#endif \ No newline at end of file diff --git a/standalone_libraries/regex.h b/standalone_libraries/regex.h index 5223523..aca1448 100644 --- a/standalone_libraries/regex.h +++ b/standalone_libraries/regex.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FIRST_REGEX_HEADER +#define FIRST_REGEX_HEADER #include #include @@ -91,3 +92,4 @@ RE_API RE_Match RE3_FindAgain(RE_Regex *regex, char *string, RE_Int len, RE_Matc RE_API RE_Int RE3_MatchFront(RE_Regex *regex, char *string, RE_Int len, char *string_front); RE_API RE_Regex *RE1_Parse(char *buff, RE_Int buffsize, char *string); RE_API RE_Regex *RE2_Parse(char *buff, RE_Int buffsize, char *string, RE_Int len); +#endif \ No newline at end of file diff --git a/standalone_libraries/string.c b/standalone_libraries/string.c index 283690f..f13a363 100644 --- a/standalone_libraries/string.c +++ b/standalone_libraries/string.c @@ -530,7 +530,7 @@ S8_API S8_String S8_AddF(S8_Allocator allocator, S8_List *list, const char *str, return result; } -#ifdef UTF_HEADER +#ifdef FIRST_UTF_HEADER S8_API S16_String S8_ToWidecharEx(S8_Allocator allocator, S8_String string) { S8_ASSERT(sizeof(wchar_t) == 2); diff --git a/standalone_libraries/string.h b/standalone_libraries/string.h index c9e4dc3..fb28dc9 100644 --- a/standalone_libraries/string.h +++ b/standalone_libraries/string.h @@ -1,5 +1,5 @@ -#pragma once -#define S8_HEADER +#ifndef FIRST_S8_STRING +#define FIRST_S8_STRING #include #include @@ -32,7 +32,7 @@ struct S8_String { S8_String(char *s, int64_t l) : str(s), len(l) {} S8_String(const char *s) : str((char *)s), len(S8_Length((char *)s)) {} S8_String(const char *s, int64_t l) : str((char *)s), len(l) {} - #if defined(UTF_HEADER) + #if defined(FIRST_UTF_HEADER) struct Iter { UTF8_Iter i; @@ -47,7 +47,7 @@ struct S8_String { Iter begin() { return {UTF8_IterateEx(str, (int)len)}; } Iter end() { return {}; } - #endif // UTF_HEADER + #endif // FIRST_UTF_HEADER #endif // __cplusplus }; @@ -192,3 +192,4 @@ inline S8_String operator""_s(const char *str, size_t size) { return {(char *)st inline bool operator==(S8_String a, S8_String b) { return S8_AreEqual(a, b, 0); } inline bool operator!=(S8_String a, S8_String b) { return !S8_AreEqual(a, b, 0); } #endif +#endif \ No newline at end of file diff --git a/standalone_libraries/table.hpp b/standalone_libraries/table.hpp index e6a7d4f..9481d02 100644 --- a/standalone_libraries/table.hpp +++ b/standalone_libraries/table.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef FIRST_TABLE_HEADER +#define FIRST_TABLE_HEADER #include /* Hash table implementation: @@ -20,7 +21,7 @@ #endif #ifndef TABLE_Allocator -#define TABLE_Allocator void * + #define TABLE_Allocator void * #endif #ifndef TABLE_ALLOCATE @@ -62,7 +63,7 @@ TABLE_PRIVATE_FUNCTION uint64_t TABLE__HashBytes(void *data, unsigned size) { TABLE_PRIVATE_FUNCTION int TABLE_CStringLen(char *str) { int i = 0; - while(str[i]) i += 1; + while (str[i]) i += 1; return i; } @@ -222,7 +223,7 @@ struct Table { return get(hash, default_value); } - #ifdef S8_HEADER +#ifdef FIRST_S8_HEADER Value *get(S8_String s) { uint64_t hash = TABLE_HASH_BYTES(s.str, (unsigned)s.len); return get(hash); @@ -237,7 +238,7 @@ struct Table { uint64_t hash = TABLE_HASH_BYTES(s.str, (unsigned)s.len); insert(hash, value); } - #endif +#endif void puts(char *str, const Value &value) { int len = TABLE_CStringLen(str); @@ -259,4 +260,5 @@ struct Table { cap = 0; values = 0; } -}; \ No newline at end of file +}; +#endif \ No newline at end of file diff --git a/standalone_libraries/unicode.h b/standalone_libraries/unicode.h index 18308ca..0622e83 100644 --- a/standalone_libraries/unicode.h +++ b/standalone_libraries/unicode.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FIRST_UTF_HEADER +#define FIRST_UTF_HEADER #define UTF_HEADER #include typedef struct UTF32_Result UTF32_Result; @@ -51,3 +52,4 @@ UTF_API UTF8_Iter UTF8_IterateEx(char *str, int len); UTF_API UTF8_Iter UTF8_Iterate(char *str); #define UTF8_For(name, str, len) for (UTF8_Iter name = UTF8_IterateEx(str, (int)len); name.item; UTF8_Advance(&name)) +#endif \ No newline at end of file