This doesn't compile as WIN32 isn't defined and VS is trying to include unistd.h.
I went to project properties -> C++ -> Preprocessor and added to "Preprocessor Definitions" : "/DWIN32", which I guessed is suppose to define WIN32 globally across the project? But this does not work.
Of course I can hard-code #define WIN32 1 but that defeats the whole purpose of it, I want this to be at the project level not in the code so that it compiles without modification in Linux.
How can I change the project so that WIN32 is defined? Thanks.
Question
Andre S. Veteran
I'm writing some code that needs to compile on both Windows and Unix. I created an empty project in Visual C++ 2008 and added this code :
This doesn't compile as WIN32 isn't defined and VS is trying to include unistd.h.
I went to project properties -> C++ -> Preprocessor and added to "Preprocessor Definitions" : "/DWIN32", which I guessed is suppose to define WIN32 globally across the project? But this does not work.
Of course I can hard-code #define WIN32 1 but that defeats the whole purpose of it, I want this to be at the project level not in the code so that it compiles without modification in Linux.
How can I change the project so that WIN32 is defined? Thanks.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts