In C, I want to add a namespace prefix string(without quotes) to all functions for which I want it to happen, and later on change the namespace string any time easily.
My approach:
#define NAMESPACE project_name
void NAMESPACE_func_name()
{
}
That should become:
void project_name_func_name()
{
}
Is that possible, how? Thanks for help in advance.
You can do it with the macro concatenation operator and function-like macros:
#define NAMESPACE(name) project_name_ ## name
void NAMESPACE(func_name)(void)
{
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With