Hello! I am trying to create a small set of filepath functions that I intend to compile across linux and windows (I prefer not to use a big library).
I want to have a global constant PATH_SEPARATOR that depends on the OS environment. This is what I set at the top of header file.
Code:
#include <stdio.h>
const char PATH_SEPARATOR =
#ifdef _WIN32
'\\';
#else
'/';
#endif
I was hoping to test this while compiling this in a linux environment using gcc, thusly:
Code:
int main (int argc, char const* argv[])
{
printf("OSNAME not defined. Separator is: %c\n", PATH_SEPARATOR);
#define _WIN32
printf("OSNAME defined. Separator is: %c\n", PATH_SEPARATOR);
#undef _WIN32
return 0;
}
which gives me the following:
Code:
_WIN32 not defined. Separator is: /
_WIN32 defined. Separator is: /
where apparently, I seem not to be able to "set" a part of the code to have "_WIN32" defined. I don't know if I explained this clearly. I'm not even sure I got the title correct.