The “correct” solution to this problem (as used by many projects) is to create a script configuration.
The configuration script performs various tests, which include compiling and running small programs to determine the properties of the compiler and the system. The script then writes the data as a header file or makefile, or both. Of course, yours can do whatever you like.
There are tools, tools for these kinds of operations, semi-automatic, but they are probably too crowded for you. If you want to take a look, the names will be autoconf and automake. Beware, they are not easy to learn, but they generate configure and make scripts that should work on almost any platform if it has a unix-style shell and GNU make.
source share