I want to make a program work and compile in both WIN\Linux .
I want to have some information about the OS which my program is ran on.
moreover I want to have a variable to decide about the code i want to be performed.
I thought about a pre-processed code to have an input to my controlling variable which I described.
So, I must have something like:
# //a preprocess code to detect the os
# define controllingVar // ?
I use C++;
You could check if the WIN32 macro has been defined:
Note that on some compilers, you might also have to check for
_WIN32, as stated in wikipedia.As an example:
Edit: since you’re asking about different
mains for each OS, here’s an example:You could also have different
mains: