You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would suggest to change the actual prefix system with something more flexible.
I really like the one header idea but current implementation doesn't allow to choose a comfortable prefix and avoid collisions at the same time.
In contrast, for example, consider the following main.c:
#include<stdio.h>#defineMYLIB_H_IMPLEMENTATION#defineMYLIB_H_PREFIX a_
// For no prefix just #define MYLIB_H_PREFIX// For default prefix no action is required#include"mylib.h"#defineANOTHERLIB_H_IMPLEMENTATION#defineANOTHERLIB_H_NAME(x) x ## _from_anotherlib
#include"anotherlib.h"intmain(intargc, char*argv[]) {
a_hello();
hello_from_anotherlib();
return0;
}
Both headers export a hello function.
For the first #include there is a simpler version in which the user choose the prefix it would like to use for the module symbols.
For the second #include there is a slightly more advanced version in which the user defines the naming macro to use for the module symbols.
The headers could be implemented as follows: mylib.h
I would suggest to change the actual prefix system with something more flexible.
I really like the one header idea but current implementation doesn't allow to choose a comfortable prefix and avoid collisions at the same time.
In contrast, for example, consider the following
main.c
:Both headers export a
hello
function.For the first
#include
there is a simpler version in which the user choose the prefix it would like to use for the module symbols.For the second
#include
there is a slightly more advanced version in which the user defines the naming macro to use for the module symbols.The headers could be implemented as follows:
mylib.h
You get the idea, anyway:
anotherlib.h
I already tried this implementation and it works as intended.
The text was updated successfully, but these errors were encountered: