S
silrandir
When calling getenv() globally, the function returns NULL, yet when
called from main, returns an appropriate value.
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
//using namespace std;
#define MW_DEBUG "TEST"
char* debugstr = getenv(MW_DEBUG);
int debug = debugstr?1:0;
int main()
{
if(debug)
write(2, "\nDEBUG Enabled\n", 15);
else
write(2, "\nDEBUG DISABLED\n", 16);
debugstr = getenv(MW_DEBUG);
if(debugstr)
write(2, "\nDebug Enabled\n", 15);
else
write(2, "\nDebug Disabled\n", 16);
}
called from main, returns an appropriate value.
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
//using namespace std;
#define MW_DEBUG "TEST"
char* debugstr = getenv(MW_DEBUG);
int debug = debugstr?1:0;
int main()
{
if(debug)
write(2, "\nDEBUG Enabled\n", 15);
else
write(2, "\nDEBUG DISABLED\n", 16);
debugstr = getenv(MW_DEBUG);
if(debugstr)
write(2, "\nDebug Enabled\n", 15);
else
write(2, "\nDebug Disabled\n", 16);
}