寫在程式中 不是寫在configure檔
利用gcc前置處理器preprocessor
看參數 __GNUC__ , __GNUC_MINOR__ , GNU_PATCHLEVEL__
範例如下
hello.c
================================================
#include
int main(int argc, char *argv[]) {
// Check GCC version (>=2.9.x)
#if ( __GNUC__ >= 3 ) \
|| ( __GNUC__ >= 2 && __GNUC_MINOR__ >= 9 )
#warning "Your GCC is good( need >=2.9.x )"
#else
#error "Your GCC Version is wrong( need >=2.9 )"
#endif
//show GCC version
printf("You are using GCC:%d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
return 0;
}
================================================
gcc -o hello hello.c
沒有留言:
張貼留言