I have a function to print debug logs which has to be toggled depending on the environment variable. Instead of checking the env var each time the print_trace()
is called, what should be the best method to store it and reuse that value?
void print_trace(const char* msg)
{
const char* s = getenv("DEBUG_TRACE");
if(!strcmp(s,"ON"))
printf(msg);
}
There is no main()
as this is a shared library.