S
silrandir
when attempting to call getenv() in global memory (c/c++), it
constantly returns null, but when called in main, it properly reads the
environment. is this expected behavior?
sample code:
#include <cstdlib>
#include <stdio.h>
#include <unistd.h>
using namespace std;
#define TEST "TEST"
int debug = getenv(TEST)?1:0;
int main()
{
if(debugstr)
write(2, "\nTEST FOUND\n", 12);
else
write(2, "\nTEST NOT FOUND\n", 16);
}
constantly returns null, but when called in main, it properly reads the
environment. is this expected behavior?
sample code:
#include <cstdlib>
#include <stdio.h>
#include <unistd.h>
using namespace std;
#define TEST "TEST"
int debug = getenv(TEST)?1:0;
int main()
{
if(debugstr)
write(2, "\nTEST FOUND\n", 12);
else
write(2, "\nTEST NOT FOUND\n", 16);
}