2013-03-28 71 views
7

我已經失敗,出現-std = C99GCC編譯失敗,並行線程和選項性病= C99

編譯一個範例程序的任何幫助讚賞

#include <pthread.h> 
int main(void) { 
    pthread_rwlock_t myLock; 
    return 0; 
} 

output of the two compiles: 
gcc pthread_test.c 
[[email protected] src]$ gcc pthread_test.c 
[[email protected] src]$ 

gcc -std=c99 pthread_test.c[[email protected] src]$ gcc -std=c99 pthread_test.c 
pthread_test.c: In function ‘main’: 
pthread_test.c:5:2: error: unknown type name ‘pthread_rwlock_t’ 
[[email protected] src]$ 
+1

'-std = gnu99'怎麼樣? – 2013-03-28 03:02:32

回答

20

讀寫鎖是非標準並且在<pthread.h>中有條件地定義。

-std=c99要求嚴格遵守標準(儘可能),並禁用語言擴展和額外的庫。

如果您改爲通過std=gnu99,您將獲得C99編譯器版本以及默認情況下由gcc提供的所有擴展和額外功能。