Web lists-archives.com

Pthreads: Prototypes missing if -std=c11




Hello,

gcc does not recognize some functions from pthread.h if option -std=c11 is used:

#include <pthread.h>
#define THREADS 5

int main (int argc, char *argv[])
{
  pthread_barrier_t barrier;
  pthread_barrier_init(&barrier, NULL, THREADS);
}

gcc -std=c11 -o test test.c
test.c: In function ‘main’:
test.c:8:3: warning: implicit declaration of function ‘pthread_barrier_init’ [-Wimplicit-function-declaration]
   pthread_barrier_init(&barrier, NULL, THREADS);
   ^

There is no warning without that option:

gcc -o test test.c

My system is:

$ uname -a
CYGWIN_NT-10.0 DESKTOP 2.8.1(0.312/5/3) 2017-07-03 14:11 x86_64 Cygwin

The compiler used is:

$ gcc --version
gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

It seems to be a __POSIX_VISIBLE issue.

Thanks


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple