Updated c_library generation to support latest changes with context struct (also prepped for static/dynamic linkage)

This commit is contained in:
2024-12-13 22:09:43 -05:00
parent 16d0e0834f
commit b5cf633e98
18 changed files with 499 additions and 451 deletions

View File

@ -5,6 +5,24 @@
#pragma region Macros
#if GEN_COMPILER_MSVC
#ifdef GEN_DYN_LINK
#ifdef GEN_EXPORTS
#define GEN_API __declspec(dllexport)
#else
#define GEN_API __declspec(dllimport)
#endif
#else
#define GEN_API // Empty for static builds
#endif
#else
#ifdef GEN_DYN_LINK
#define GEN_API __attribute__((visibility("default")))
#else
#define GEN_API // Empty for static builds
#endif
#endif
#ifndef global
#define global static // Global variables
#endif
@ -69,8 +87,13 @@
#endif
#ifndef do_once
#define do_once() for ( local_persist b32 once = true; once; once = false )
#define do_once_defer( statement ) for ( local_persist b32 once = true; once; once = false, (statement) )
#define do_once() \
static int __do_once_counter_##__LINE__ = 0; \
for(; __do_once_counter_##__LINE__ != 1; __do_once_counter_##__LINE__ = 1 ) \
#define do_once_defer( expression ) \
static int __do_once_counter_##__LINE__ = 0; \
for(; __do_once_counter_##__LINE__ != 1; __do_once_counter_##__LINE__ = 1, (expression)) \
#define do_once_start \
do \