====== Différences ====== Ci-dessous, les différences entre deux révisions de la page.
misc:c_preproc_os_compiler_detection [2011/10/31 15:55] 127.0.0.1 modification externe |
misc:c_preproc_os_compiler_detection [2011/11/06 18:14] (Version actuelle) mrhide |
||
---|---|---|---|
Ligne 2: | Ligne 2: | ||
Pour détecter une majorité d'OS et de compilateurs (les plus répandus) : | Pour détecter une majorité d'OS et de compilateurs (les plus répandus) : | ||
- | <code c> | + | <file c main.c> |
#include <stdio.h> | #include <stdio.h> | ||
#include <stdlib.h> | #include <stdlib.h> | ||
Ligne 8: | Ligne 8: | ||
int main(int argc, char*argv[]) { | int main(int argc, char*argv[]) { | ||
- | printf("OS detection :\n"); | + | puts("OS detection :"); |
#if defined(linux) | #if defined(linux) | ||
- | puts("\tLinux detected !\n"); | + | puts("\tLinux detected !"); |
#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) | #elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) | ||
- | puts("\tWindows detected !\n"); | + | puts("\tWindows detected !"); |
#elif defined(__APPLE__) || defined(macintosh) | #elif defined(__APPLE__) || defined(macintosh) | ||
- | puts("\tMac detected !\n"); | + | puts("\tMac detected !"); |
#elif defined(BSD) | #elif defined(BSD) | ||
- | puts("\tBSD detected !\n"); | + | puts("\tBSD detected !"); |
#elif defined(sun) | #elif defined(sun) | ||
- | puts("\tSolaris detected !\n"); | + | puts("\tSolaris detected !"); |
#endif | #endif | ||
- | printf("\nCOMPILER detection :\n"); | + | puts("\nCOMPILER detection :"); |
#if defined(__INTEL_COMPILER) | #if defined(__INTEL_COMPILER) | ||
- | puts("\tICC detected !\n"); | + | puts("\tICC detected !"); |
#elif defined(__BORLANDC__) | #elif defined(__BORLANDC__) | ||
- | puts("\tBCC detected !\n"); | + | puts("\tBCC detected !"); |
#elif defined(_MSC_VER) | #elif defined(_MSC_VER) | ||
- | puts("\tVisual C++ detected !\n"); | + | puts("\tVisual C++ detected !"); |
#elif defined(__LCC__) | #elif defined(__LCC__) | ||
- | puts("\tLCC detected !\n"); | + | puts("\tLCC detected !"); |
#elif defined(__TINYC__) | #elif defined(__TINYC__) | ||
- | puts("\tTinyCC detected !\n"); | + | puts("\tTinyCC detected !"); |
#elif defined(__GNUC__) /* GCC doit être en dernier car ICC et d'autres définissent aussi cette macro */ | #elif defined(__GNUC__) /* GCC doit être en dernier car ICC et d'autres définissent aussi cette macro */ | ||
- | puts("\tGCC detected !\n"); | + | puts("\tGCC detected !"); |
#endif | #endif | ||
return 0; | return 0; | ||
} | } | ||
- | </code> | + | </file> |
Pour gérer plus d'OS/compilateurs, lisez http://predef.sourceforge.net/precomp.html | Pour gérer plus d'OS/compilateurs, lisez http://predef.sourceforge.net/precomp.html |