Due to lack of proper namespacing in C, library authors prefix their symbols with the name of the library
Example: https://github.com/floooh/sokol/blob/master/sokol_gfx.h#L2471 (large file)
SOKOL_GFX_API_DECL void sg_setup(const sg_desc* desc);
SOKOL_GFX_API_DECL void sg_shutdown(void);
SOKOL_GFX_API_DECL bool sg_isvalid(void);
SOKOL_GFX_API_DECL void sg_reset_state_cache(void);
SOKOL_GFX_API_DECL sg_trace_hooks sg_install_trace_hooks(const sg_trace_hooks* trace_hooks);
SOKOL_GFX_API_DECL void sg_push_debug_group(const char* name);
SOKOL_GFX_API_DECL void sg_pop_debug_group(void);
Would be cool to be able to do something like this:
module sokol;
pragma(mangle_prefix, "sg_"):
extern(C):
void setup(const(desc)* desc);
void shutdown();
bool isvalid();
void reset_state_cache();
trace_hooks install_trace_hooks(const trace_hooks* trace_hooks);
void push_debug_group(const(char)* name);
void pop_debug_group();
And use them this way:
import sg = sokol; // i love this D feature, so nice to use
void main()
{
sg.desc description;
sg.setup(&description);
sg.shutdown();
}
This way we get a nice way to contain C functions into their own scope without polluting the global scope
Got the idea from: https://odin-lang.org/docs/overview/#linking-and-foreign-attributes
If nobody finds it bad, then i can try to implement it myself, that doesn't look as intimidating to do as the .Enum dip