If you are getting the information to determine which compatible code to use for each system, try this:
Code:
#include <stdio.h>
#include <stdlib.h>
#ifdef _POSIX_
#define PRINTF "POSIX"
#elif _WIN32
#define PRINT "Windows"
#elif _LINUX_
#define PRINT "Linux"
#elif _MAC
#define PRINT "Mac"
#endif
int main ( void )
{
puts ( PRINT );
return EXIT_SUCCESS;
}
I'm not sure if the last two #elif's use the correct variable, but the first two do. If you simply want information on the environment of your system, this should work nicely if your compiler supports the char **env argument to main.
Code:
#include <stdio.h>
#include <stdlib.h>
/* Nonstandard arguments to main.
** This program may not work on
** all systems.
*/
int main ( int argc, char **argv, char **env )
{
int i;
for ( i = 0; env[i] != NULL; i++ )
(void)puts ( env[i] );
return EXIT_SUCCESS;
}
-Prelude