찾아 본 자료

OS감지 전처리기

xaida 2018. 1. 9. 17:54

컴파일러 매크로리스트 http://sourceforge.net/p/predef/wiki/OperatingSystems/

GCC 컴파일러 매크로리스트 http://gcc.gnu.org/onlinedocs/cpp/Predefined-Macros.html


gcc 예제

#ifdef _WIN32 //define something for Windows (32-bit and 64-bit, this part is common) #ifdef _WIN64 //define something for Windows (64-bit only) #endif #elif __APPLE__ #include "TargetConditionals.h" #if TARGET_IPHONE_SIMULATOR // iOS Simulator #elif TARGET_OS_IPHONE // iOS device #elif TARGET_OS_MAC // Other kinds of Mac OS #else # error "Unknown Apple platform" #endif #elif __linux__ // linux #elif __unix__ // all unices not caught above // Unix #elif defined(_POSIX_VERSION) // POSIX #else # error "Unknown compiler" #endif




출처: http://hashcode.co.kr/questions/594/c%EC%A0%84%EC%B2%98%EB%A6%AC%EA%B8%B0%EC%97%90%EC%84%9C-osos-x%EB%A6%AC%EB%88%85%EC%8A%A4%EC%9C%88%EB%8F%84%EC%9A%B0-%EB%93%B1%EC%9D%84-%EA%B0%90%EC%A7%80%ED%95%98%EB%A0%A4%EB%A9%B4