Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC compile fails with pthread and option std=c99

I have an exemplar program that fails to compile with -std=c99

any help appreciated

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

output of the two compiles:
gcc pthread_test.c
[brad@fedora17onbradsmacpro src]$ gcc  pthread_test.c
[brad@fedora17onbradsmacpro src]$

gcc -std=c99 pthread_test.c[brad@fedora17onbradsmacpro 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’
[brad@fedora17onbradsmacpro src]$
like image 892
user2218165 Avatar asked Mar 28 '13 02:03

user2218165


1 Answers

The Read-Write locks are non-standard, and are conditionally defined in <pthread.h>.

-std=c99 requests close compliance to the Standard (as much as possible), and disables both language extensions and extra libraries.

If you instead pass std=gnu99, you will get the C99 compiler version and also all the extensions and extras provided by gcc by default.

like image 134
Ben Voigt Avatar answered Oct 19 '22 00:10

Ben Voigt