From cd7f02a3dbcc20eea3f9c6043491715a417e4996 Mon Sep 17 00:00:00 2001 From: 0scar Date: Sun, 18 Feb 2024 10:58:48 +0100 Subject: Add C++ header guard --- src/core/include/engine/core/dltools.h | 7 +++++ src/core/include/engine/core/logging.h | 7 +++++ src/core/include/engine/core/memory.h | 7 +++++ src/core/include/engine/core/platform.h | 7 +++++ src/core/include/engine/core/state.h | 7 +++++ src/core/include/engine/core/thread.h | 7 +++++ src/core/include/engine/core/types.h | 7 +++++ src/core/include/engine/engine.h | 7 +++++ src/ctrl/include/engine/ctrl/input.h | 7 +++++ src/ctrl/include/engine/ctrl/scancodes.h | 7 +++++ src/rendering/include/engine/rendering/rendering.h | 7 +++++ src/rendering/include/engine/rendering/window.h | 7 +++++ src/resources/include/engine/resources.h | 7 +++++ src/resources/include/engine/resources/texture.h | 7 +++++ src/utils/include/engine/utils.h | 7 +++++ src/utils/include/engine/utils/btree.h | 7 +++++ src/utils/include/engine/utils/fov.h | 7 +++++ src/utils/include/engine/utils/hashmap.h | 7 +++++ src/utils/include/engine/utils/list.h | 7 +++++ src/utils/include/engine/utils/stack.h | 31 +++++----------------- src/utils/include/engine/utils/vector.h | 8 ++++++ 21 files changed, 148 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/core/include/engine/core/dltools.h b/src/core/include/engine/core/dltools.h index 5a53f49..d9c74ee 100644 --- a/src/core/include/engine/core/dltools.h +++ b/src/core/include/engine/core/dltools.h @@ -1,6 +1,10 @@ #ifndef DLTOOLS_H #define DLTOOLS_H +#ifdef __cplusplus +extern "C" { +#endif + #include /* Utility functions for handling runtime linked shared libraries */ @@ -13,4 +17,7 @@ void* dynamic_library_reload(void* shared_library, const char* library_path); void* dynamic_library_get_symbol(void* shared_library, const char* symbol); char* dynamic_library_get_error(void); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/core/include/engine/core/logging.h b/src/core/include/engine/core/logging.h index 52bb446..cd55442 100644 --- a/src/core/include/engine/core/logging.h +++ b/src/core/include/engine/core/logging.h @@ -1,6 +1,10 @@ #ifndef LOGGING_H #define LOGGING_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -46,4 +50,7 @@ void WARN(const char* fmt, ...); void ERROR(const char* fmt, ...); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/core/include/engine/core/memory.h b/src/core/include/engine/core/memory.h index dbdd065..d04d58e 100644 --- a/src/core/include/engine/core/memory.h +++ b/src/core/include/engine/core/memory.h @@ -1,6 +1,10 @@ #ifndef MEMORY_H #define MEMORY_H +#ifdef __cplusplus +extern "C" { +#endif + #include typedef struct memory { @@ -21,4 +25,7 @@ void memory_free(memory* mem, usize size); void memory_clear(memory* mem); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/core/include/engine/core/platform.h b/src/core/include/engine/core/platform.h index 76137c9..9fe22b3 100644 --- a/src/core/include/engine/core/platform.h +++ b/src/core/include/engine/core/platform.h @@ -1,6 +1,10 @@ #ifndef ENGINE_CORE_PLATFORM_H #define ENGINE_CORE_PLATFORM_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -51,4 +55,7 @@ typedef struct Platform { binding_t bindings_global[NUM_GLOBAL_BINDINGS]; } Platform; +#ifdef __cplusplus +} +#endif #endif diff --git a/src/core/include/engine/core/state.h b/src/core/include/engine/core/state.h index ee4741e..a6a5e84 100644 --- a/src/core/include/engine/core/state.h +++ b/src/core/include/engine/core/state.h @@ -1,6 +1,10 @@ #ifndef STATE_H #define STATE_H +#ifdef __cplusplus +extern "C" { +#endif + #include typedef enum StateType { @@ -31,4 +35,7 @@ bool state_refresh_input_ctx(void* lib, i_ctx** ctx, usize ctx_len); #endif +#ifdef __cplusplus +} +#endif #endif diff --git a/src/core/include/engine/core/thread.h b/src/core/include/engine/core/thread.h index ee61893..3d2e6b9 100644 --- a/src/core/include/engine/core/thread.h +++ b/src/core/include/engine/core/thread.h @@ -1,6 +1,10 @@ #ifndef THREAD_H #define THREAD_H +#ifdef __cplusplus +extern "C" { +#endif + #include typedef u64 thread_t; @@ -9,4 +13,7 @@ typedef void*(thread_fn(void*)); thread_t thread_spawn(thread_fn* routine, void* arg); void thread_join(thread_t thread); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/core/include/engine/core/types.h b/src/core/include/engine/core/types.h index 934cb63..a7d794d 100644 --- a/src/core/include/engine/core/types.h +++ b/src/core/include/engine/core/types.h @@ -1,6 +1,10 @@ #ifndef ENGINE_TYPES_H #define ENGINE_TYPES_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -31,4 +35,7 @@ typedef i32 isize; typedef bool(predicate_t)(const void*); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/core/include/engine/engine.h b/src/core/include/engine/engine.h index 75f6313..9036520 100644 --- a/src/core/include/engine/engine.h +++ b/src/core/include/engine/engine.h @@ -1,6 +1,10 @@ #ifndef ENGINE_ENGINE_H #define ENGINE_ENGINE_H +#ifdef __cplusplus +extern "C" { +#endif + #include /* TODO: Cleanup the includes, ideally this header file should only include all @@ -48,4 +52,7 @@ v2_i32* get_mousepos(void); /* move this */ void delay(uint32_t ms); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/ctrl/include/engine/ctrl/input.h b/src/ctrl/include/engine/ctrl/input.h index d06dcfe..55a8c15 100644 --- a/src/ctrl/include/engine/ctrl/input.h +++ b/src/ctrl/include/engine/ctrl/input.h @@ -1,6 +1,10 @@ #ifndef ENGINE_CTRL_INPUT_H #define ENGINE_CTRL_INPUT_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -92,4 +96,7 @@ void i_bind_alt(binding_t* b, scancode_t s); .scancode = key, .scancode_alt = altkey, .since_last_activation = 0 \ } +#ifdef __cplusplus +} +#endif #endif diff --git a/src/ctrl/include/engine/ctrl/scancodes.h b/src/ctrl/include/engine/ctrl/scancodes.h index 90bd749..f01394e 100644 --- a/src/ctrl/include/engine/ctrl/scancodes.h +++ b/src/ctrl/include/engine/ctrl/scancodes.h @@ -1,5 +1,9 @@ #ifndef ENGINE_CTRL_SCANCODES_H +#ifdef __cplusplus +extern "C" { +#endif + // We want to reserve the following bytes marked with X for MODS, // one bit per MODIFIER (shift, control, alt, super): // XXXX 0000 0000 0000 0000 0000 0000 0000 @@ -79,4 +83,7 @@ typedef enum { #undef ACTION #undef MOD +#ifdef __cplusplus +} +#endif #endif diff --git a/src/rendering/include/engine/rendering/rendering.h b/src/rendering/include/engine/rendering/rendering.h index 2940490..2a386ee 100644 --- a/src/rendering/include/engine/rendering/rendering.h +++ b/src/rendering/include/engine/rendering/rendering.h @@ -1,6 +1,10 @@ #ifndef ENGINE_RENDERING_RENDERING_H #define ENGINE_RENDERING_RENDERING_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -139,4 +143,7 @@ u32 ComposeShader(u32 *shaders, usize shaders_len); ShaderType guess_shadertype_from_filename(const char *restrict fname); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/rendering/include/engine/rendering/window.h b/src/rendering/include/engine/rendering/window.h index bd4eb9c..1111250 100644 --- a/src/rendering/include/engine/rendering/window.h +++ b/src/rendering/include/engine/rendering/window.h @@ -1,6 +1,10 @@ #ifndef WINDOW_H #define WINDOW_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -40,4 +44,7 @@ void destroy_window(Window* w); void init_render_opengl(Window* w); #undef API +#ifdef __cplusplus +} +#endif #endif diff --git a/src/resources/include/engine/resources.h b/src/resources/include/engine/resources.h index cefae24..fe78a7d 100644 --- a/src/resources/include/engine/resources.h +++ b/src/resources/include/engine/resources.h @@ -1,6 +1,10 @@ #ifndef ENGINE_RESOURCES_H #define ENGINE_RESOURCES_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -112,4 +116,7 @@ isize resource_make_global(isize resource_id); #include +#ifdef __cplusplus +} +#endif #endif diff --git a/src/resources/include/engine/resources/texture.h b/src/resources/include/engine/resources/texture.h index 8266957..979dd25 100644 --- a/src/resources/include/engine/resources/texture.h +++ b/src/resources/include/engine/resources/texture.h @@ -1,6 +1,10 @@ #ifndef TEXTURE_H #define TEXTURE_H +#ifdef __cplusplus +extern "C" { +#endif + #include typedef struct { @@ -11,4 +15,7 @@ typedef struct { Texture* load_texture(void* render, const Asset_TextureSpec* ts); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/utils/include/engine/utils.h b/src/utils/include/engine/utils.h index d10a03a..aa1343b 100644 --- a/src/utils/include/engine/utils.h +++ b/src/utils/include/engine/utils.h @@ -1,6 +1,10 @@ #ifndef ENGINE_UTILS_H #define ENGINE_UTILS_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -33,4 +37,7 @@ i32* kernmap(const void* map, i32* dstmap, const v2_i32 mapsize, /* Returns an index from the given weights. */ i32 pick_from_sample(const i32* weights, i32 len); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/utils/include/engine/utils/btree.h b/src/utils/include/engine/utils/btree.h index 04f9ff8..1dd2023 100644 --- a/src/utils/include/engine/utils/btree.h +++ b/src/utils/include/engine/utils/btree.h @@ -1,6 +1,10 @@ #ifndef BTREE_H #define BTREE_H +#ifdef __cplusplus +extern "C" { +#endif + #include #define BTREE_DEGREE_DEFAULT 4 @@ -51,4 +55,7 @@ void btree_iter_t_reset(struct btree* tree, struct btree_iter_t** it); void* btree_iter(struct btree* tree, struct btree_iter_t* iter); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/utils/include/engine/utils/fov.h b/src/utils/include/engine/utils/fov.h index b083d2b..50df8fa 100644 --- a/src/utils/include/engine/utils/fov.h +++ b/src/utils/include/engine/utils/fov.h @@ -1,6 +1,10 @@ #ifndef ENGINE_FOV_H #define ENGINE_FOV_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -18,4 +22,7 @@ void fov_shadowcast(const void* map, const v2_i32 mapsize, bool (*visblocking)(const void*), i32* lightmap, const i32 range, v2_i32 src); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/utils/include/engine/utils/hashmap.h b/src/utils/include/engine/utils/hashmap.h index 046c810..d8fdbf2 100644 --- a/src/utils/include/engine/utils/hashmap.h +++ b/src/utils/include/engine/utils/hashmap.h @@ -1,6 +1,10 @@ #ifndef ENGINE_HASHMAP_H #define ENGINE_HASHMAP_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -51,4 +55,7 @@ i32 lolhash(const usize s, i32 v); } \ } +#ifdef __cplusplus +} +#endif #endif diff --git a/src/utils/include/engine/utils/list.h b/src/utils/include/engine/utils/list.h index 37857f0..04dda04 100644 --- a/src/utils/include/engine/utils/list.h +++ b/src/utils/include/engine/utils/list.h @@ -1,6 +1,10 @@ #ifndef ENGINE_LIST_H #define ENGINE_LIST_H +#ifdef __cplusplus +extern "C" { +#endif + #define DEFINE_LLIST(type) \ struct List_##type { \ type value; \ @@ -8,4 +12,7 @@ /* Force the user to add `;` for style consistency */ \ } List_##type +#ifdef __cplusplus +} +#endif #endif diff --git a/src/utils/include/engine/utils/stack.h b/src/utils/include/engine/utils/stack.h index 9fc53aa..b8e1807 100644 --- a/src/utils/include/engine/utils/stack.h +++ b/src/utils/include/engine/utils/stack.h @@ -1,30 +1,10 @@ -/* Copyright © 2021 Upqwerk - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the “Software”), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * */ - -/* Stack implementation - * Author: Upqwerk - */ #ifndef STACK_H #define STACK_H +#ifdef __cplusplus +extern "C" { +#endif + #include typedef struct { @@ -47,4 +27,7 @@ void* stack_peek(Stack* s); isize stack_size(const Stack* s); void stack_swap(Stack* s, Stack* t); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/utils/include/engine/utils/vector.h b/src/utils/include/engine/utils/vector.h index 11517dc..7f4c4a4 100644 --- a/src/utils/include/engine/utils/vector.h +++ b/src/utils/include/engine/utils/vector.h @@ -1,6 +1,10 @@ #ifndef VECTOR_H #define VECTOR_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -28,4 +32,8 @@ v2_i32 v2_i32_min(v2_i32 a, v2_i32 b); v2_i32 v2_i32_lerp(f32 dt, v2_i32 a, v2_i32 b); void v2_i32_fprintf(FILE* stream, v2_i32 a); + +#ifdef __cplusplus +} +#endif #endif -- cgit v1.3