Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
wposix.cpp File Reference
#include "precompiled.h"
#include "lib/sysdep/os/win/wposix/wposix.h"
#include "lib/sysdep/os/win/wposix/wposix_internal.h"
#include "lib/bits.h"
Include dependency graph for wposix.cpp:

Functions

int setenv (const char *envname, const char *envval, int overwrite)
 rationale: the Windows headers declare many POSIX functions (e.g. More...
 

Function Documentation

◆ setenv()

int setenv ( const char *  envname,
const char *  envval,
int  overwrite 
)

rationale: the Windows headers declare many POSIX functions (e.g.

read). unfortunately, these are often slightly incorrect (size_t vs. size_t). to avert trouble in user code caused by these differences, we declare all functions ourselves according to SUSv3 and do not use the headers.

however, it does not end there. some other libraries (e.g. wxWidgets) will want to pull in these headers, which would conflict with our declarations. also, our implementation uses the actual CRT code, so we want those functions (e.g. _read) to be declared correctly even if switching compiler/CRT version.

how can these conflicting requirements be reconciled? our headers #include "no_crt_posix.h" to #define the CRT headers' include guards and thus prevent them from declaring anything. the implementation files #include "crt_posix.h", which pulls in the CRT headers (even if "no_crt_posix.h" was previously included, e.g. in the PCH). note that the CRT headers would still cause conflicts with the POSIX function declarations, but we are able to prevent this via STDC.