undef min and max for msvc compilation

undef min and max for msvc compilation

Return to topic list

Sat Oct 28 05:43:16 2023   by   Mizuki
unfortunately on windows the macro min and max is defined in its standard header, which seems to be a very bad thing: https://stackoverflow.com/a/4234022, and which is the reason planet.c does not compile with msvc.
The best solution seems to be just undef min and max if compiling to windows.

#include <string.h>
#include <stdlib.h>
#include <string.h>
/* insert between system include and your own code */
#ifdef WIN32
#undef min
#undef max
#elif _ WIN32 (remove the space)
#undef min
#undef max
#endif

int BLACK = 0;
int WHITE = 1;
 
Sat Oct 28 05:43:43 2023   by   Mizuki
Doing this allow planet to be compiled with msvc.
 
Mon Oct 30 12:42:20 2023   by   Torben
Thanks.  It will be included in the next release.
 
Tue Oct 31 14:49:10 2023   by   Mizuki
Also may I ask if -pf does anything?
In the code it just results in an exit and is actively not used in other places (like view !=f)
And the dofile also?
It seems like the only place where it matters is compiling to Macintosh, where it's set as 1, else it's always 0.
 
Wed Nov 1 10:09:58 2023   by   Torben
The -pf option is a leftover from an earlier version and has been superseded by the -M option. I will remove it.

The do_ file variable is set to 1 if the -o option is used.  If it is 0, the output will be to the standard output stream.
 
Wed Nov 1 15:56:34 2023   by   Mizuki
right, but it seems macintosh requires do_ file to be set to 1 no matter what?
 

Return to topic list



New message:
Topic:
Posted by:

Type the values of the dice shown below:

Return to topic list