Replace pragma onces with guards because preproc names are useful
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
#pragma once
|
#ifndef FIRST_CORE_HEADER
|
||||||
|
#define FIRST_CORE_HEADER
|
||||||
|
|
||||||
#include "../standalone_libraries/preproc_env.h"
|
#include "../standalone_libraries/preproc_env.h"
|
||||||
#include "../standalone_libraries/stb_sprintf.h"
|
#include "../standalone_libraries/stb_sprintf.h"
|
||||||
#include "../standalone_libraries/io.h"
|
#include "../standalone_libraries/io.h"
|
||||||
@@ -29,3 +31,5 @@
|
|||||||
if (!allocator.p) allocator = M_GetSystemAllocator();
|
if (!allocator.p) allocator = M_GetSystemAllocator();
|
||||||
#include "../standalone_libraries/array.hpp"
|
#include "../standalone_libraries/array.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef FIRST_ARRAY_HEADER
|
||||||
|
#define FIRST_ARRAY_HEADER
|
||||||
|
|
||||||
#ifndef ARRAY_REALLOCATE
|
#ifndef ARRAY_REALLOCATE
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -33,7 +34,7 @@
|
|||||||
// if (it == 4) ForArrayRemovableDeclare();
|
// if (it == 4) ForArrayRemovableDeclare();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
#ifdef DEFER_HEADER
|
#ifdef FIRST_DEFER_HEADER
|
||||||
#define ForArrayRemovable(a) for (int __i = 0; __i < (a).len; __i += 1)
|
#define ForArrayRemovable(a) for (int __i = 0; __i < (a).len; __i += 1)
|
||||||
#define ForArrayRemovablePrepare(a) \
|
#define ForArrayRemovablePrepare(a) \
|
||||||
auto &it = (a)[__i]; \
|
auto &it = (a)[__i]; \
|
||||||
@@ -48,7 +49,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef For
|
#ifndef For
|
||||||
#define For2(it, array) for(auto &it : (array))
|
#define For2(it, array) for (auto &it : (array))
|
||||||
#define For(array) For2(it, array)
|
#define For(array) For2(it, array)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -301,3 +302,5 @@ struct Array {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
#pragma once
|
#ifndef FIRST_CL_HEADER
|
||||||
|
#define FIRST_CL_HEADER
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@@ -296,3 +298,5 @@ CL_INLINE bool CL_IsKeywordOrIdent(CL_Kind kind) {
|
|||||||
bool result = CL_IsKeyword(kind) || kind == CL_IDENTIFIER;
|
bool result = CL_IsKeyword(kind) || kind == CL_IDENTIFIER;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#ifndef FIRST_DEFER_HEADER
|
||||||
#define DEFER_HEADER
|
#define FIRST_DEFER_HEADER
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct DEFER_ExitScope {
|
struct DEFER_ExitScope {
|
||||||
@@ -21,3 +21,5 @@ class DEFER_ExitScopeHelp {
|
|||||||
#define DEFER_CONCAT_INTERNAL(x, y) x##y
|
#define DEFER_CONCAT_INTERNAL(x, y) x##y
|
||||||
#define DEFER_CONCAT(x, y) DEFER_CONCAT_INTERNAL(x, y)
|
#define DEFER_CONCAT(x, y) DEFER_CONCAT_INTERNAL(x, y)
|
||||||
#define defer const auto DEFER_CONCAT(defer__, __LINE__) = DEFER_ExitScopeHelp() + [&]()
|
#define defer const auto DEFER_CONCAT(defer__, __LINE__) = DEFER_ExitScopeHelp() + [&]()
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef FIRST_HASH_HEADER
|
||||||
|
#define FIRST_HASH_HEADER
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifndef HASH_API_FUNCTION
|
#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)))
|
#define WRAP_AROUND_POWER_OF_2(x, pow2) (((x) & ((pow2)-1llu)))
|
||||||
static inline float GetRandomNormalF(RandomSeed *series) { return (float)GetRandomNormal(series); }
|
static inline float GetRandomNormalF(RandomSeed *series) { return (float)GetRandomNormal(series); }
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef FIRST_IO_HEADER
|
||||||
|
#define FIRST_IO_HEADER
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifndef IO_API
|
#ifndef IO_API
|
||||||
@@ -87,3 +88,4 @@ const int IO_KindWarningf = 2;
|
|||||||
|
|
||||||
#define IO_Printf(...) IO__Printf(IO_KindPrintf, __FILE__, __LINE__, __VA_ARGS__)
|
#define IO_Printf(...) IO__Printf(IO_KindPrintf, __FILE__, __LINE__, __VA_ARGS__)
|
||||||
#define IO_Warningf(...) IO__Printf(IO_KindWarningf, __FILE__, __LINE__, __VA_ARGS__)
|
#define IO_Warningf(...) IO__Printf(IO_KindWarningf, __FILE__, __LINE__, __VA_ARGS__)
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef FIRST_LL_HEADER
|
||||||
|
#define FIRST_LL_HEADER
|
||||||
#define SLL_QUEUE_ADD_MOD(f, l, n, next) \
|
#define SLL_QUEUE_ADD_MOD(f, l, n, next) \
|
||||||
do { \
|
do { \
|
||||||
(n)->next = 0; \
|
(n)->next = 0; \
|
||||||
@@ -123,3 +124,4 @@
|
|||||||
} while (0)
|
} while (0)
|
||||||
#define DLL_INSERT_NEXT(base, new) DLL_INSERT_NEXT_MOD(base, new, next, prev)
|
#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)
|
#define DLL_INSERT_PREV(base, new) DLL_INSERT_NEXT_MOD(base, new, next, prev)
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef FIRST_LIB_HEADER
|
||||||
|
#define FIRST_LIB_HEADER
|
||||||
typedef void *LIB_Library;
|
typedef void *LIB_Library;
|
||||||
|
|
||||||
LIB_Library LIB_LoadLibrary(char *str);
|
LIB_Library LIB_LoadLibrary(char *str);
|
||||||
@@ -8,3 +9,4 @@ bool LIB_UnloadLibrary(LIB_Library lib);
|
|||||||
#ifndef LIB_EXPORT
|
#ifndef LIB_EXPORT
|
||||||
#define LIB_EXPORT __declspec(dllexport)
|
#define LIB_EXPORT __declspec(dllexport)
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef FIRST_MU_HEADER
|
||||||
|
#define FIRST_MU_HEADER
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@@ -366,3 +367,4 @@ typedef struct MU_Event {
|
|||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef FIRST_ENV_HEADER
|
||||||
|
#define FIRST_ENV_HEADER
|
||||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
#endif
|
#endif
|
||||||
@@ -116,3 +117,4 @@
|
|||||||
// #pragma clang diagnostic push
|
// #pragma clang diagnostic push
|
||||||
// #pragma clang diagnostic ignored "-Wmicrosoft-enum-forward-reference"
|
// #pragma clang diagnostic ignored "-Wmicrosoft-enum-forward-reference"
|
||||||
// #endif
|
// #endif
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef FIRST_REGEX_HEADER
|
||||||
|
#define FIRST_REGEX_HEADER
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
@@ -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_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 *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);
|
RE_API RE_Regex *RE2_Parse(char *buff, RE_Int buffsize, char *string, RE_Int len);
|
||||||
|
#endif
|
||||||
@@ -530,7 +530,7 @@ S8_API S8_String S8_AddF(S8_Allocator allocator, S8_List *list, const char *str,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef UTF_HEADER
|
#ifdef FIRST_UTF_HEADER
|
||||||
|
|
||||||
S8_API S16_String S8_ToWidecharEx(S8_Allocator allocator, S8_String string) {
|
S8_API S16_String S8_ToWidecharEx(S8_Allocator allocator, S8_String string) {
|
||||||
S8_ASSERT(sizeof(wchar_t) == 2);
|
S8_ASSERT(sizeof(wchar_t) == 2);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#ifndef FIRST_S8_STRING
|
||||||
#define S8_HEADER
|
#define FIRST_S8_STRING
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ struct S8_String {
|
|||||||
S8_String(char *s, int64_t l) : str(s), len(l) {}
|
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) : str((char *)s), len(S8_Length((char *)s)) {}
|
||||||
S8_String(const char *s, int64_t l) : str((char *)s), len(l) {}
|
S8_String(const char *s, int64_t l) : str((char *)s), len(l) {}
|
||||||
#if defined(UTF_HEADER)
|
#if defined(FIRST_UTF_HEADER)
|
||||||
struct Iter {
|
struct Iter {
|
||||||
UTF8_Iter i;
|
UTF8_Iter i;
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ struct S8_String {
|
|||||||
|
|
||||||
Iter begin() { return {UTF8_IterateEx(str, (int)len)}; }
|
Iter begin() { return {UTF8_IterateEx(str, (int)len)}; }
|
||||||
Iter end() { return {}; }
|
Iter end() { return {}; }
|
||||||
#endif // UTF_HEADER
|
#endif // FIRST_UTF_HEADER
|
||||||
#endif // __cplusplus
|
#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); }
|
||||||
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
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef FIRST_TABLE_HEADER
|
||||||
|
#define FIRST_TABLE_HEADER
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
/*
|
/*
|
||||||
Hash table implementation:
|
Hash table implementation:
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TABLE_Allocator
|
#ifndef TABLE_Allocator
|
||||||
#define TABLE_Allocator void *
|
#define TABLE_Allocator void *
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TABLE_ALLOCATE
|
#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) {
|
TABLE_PRIVATE_FUNCTION int TABLE_CStringLen(char *str) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(str[i]) i += 1;
|
while (str[i]) i += 1;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +223,7 @@ struct Table {
|
|||||||
return get(hash, default_value);
|
return get(hash, default_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef S8_HEADER
|
#ifdef FIRST_S8_HEADER
|
||||||
Value *get(S8_String s) {
|
Value *get(S8_String s) {
|
||||||
uint64_t hash = TABLE_HASH_BYTES(s.str, (unsigned)s.len);
|
uint64_t hash = TABLE_HASH_BYTES(s.str, (unsigned)s.len);
|
||||||
return get(hash);
|
return get(hash);
|
||||||
@@ -237,7 +238,7 @@ struct Table {
|
|||||||
uint64_t hash = TABLE_HASH_BYTES(s.str, (unsigned)s.len);
|
uint64_t hash = TABLE_HASH_BYTES(s.str, (unsigned)s.len);
|
||||||
insert(hash, value);
|
insert(hash, value);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void puts(char *str, const Value &value) {
|
void puts(char *str, const Value &value) {
|
||||||
int len = TABLE_CStringLen(str);
|
int len = TABLE_CStringLen(str);
|
||||||
@@ -260,3 +261,4 @@ struct Table {
|
|||||||
values = 0;
|
values = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef FIRST_UTF_HEADER
|
||||||
|
#define FIRST_UTF_HEADER
|
||||||
#define UTF_HEADER
|
#define UTF_HEADER
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
typedef struct UTF32_Result UTF32_Result;
|
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);
|
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))
|
#define UTF8_For(name, str, len) for (UTF8_Iter name = UTF8_IterateEx(str, (int)len); name.item; UTF8_Advance(&name))
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user