public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: Pthreads: Prototypes missing if -std=c11
@ 2017-07-13 15:36 bz0815
  2017-07-13 17:38 ` cyg Simple
  2017-07-13 19:30 ` Brian Inglis
  0 siblings, 2 replies; 5+ messages in thread
From: bz0815 @ 2017-07-13 15:36 UTC (permalink / raw)
  To: cygwin

> On 2017-07-12 11:15, bz0815@tirol.com wrote:
>> gcc does not recognize some functions from pthread.h if option -std=c11 is used:
>
> Exactly, and the same happens with glibc.  When you use -std=c*, that means you are declaring strict ISO C, and all extensions are disabled by > default unless explicitly enabled (e.g. with -D_POSIX_C_SOURCE=200112L).
>  If you are not compatible with ISO C, then you should be using
> -std=gnu* instead.
>
> --
> Yaakov
>
> --

Many thanks for the info, Yaakov. Accoring to the manual -std determines the language standard and c11 means ISO C11, the 2011 revision of the ISO C standard. Howevery, I find no restriction on POSIX in ISO/IEC 9899:2011. So why should -std=c11 have an influence on Pthreads? Am I missing something?


--
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Pthreads: Prototypes missing if -std=c11
  2017-07-13 15:36 Pthreads: Prototypes missing if -std=c11 bz0815
@ 2017-07-13 17:38 ` cyg Simple
  2017-07-13 19:30 ` Brian Inglis
  1 sibling, 0 replies; 5+ messages in thread
From: cyg Simple @ 2017-07-13 17:38 UTC (permalink / raw)
  To: cygwin

On 7/13/2017 11:36 AM, bz0815@tirol.com wrote:
>> On 2017-07-12 11:15, bz0815@tirol.com wrote:
>>> gcc does not recognize some functions from pthread.h if option -std=c11 is used:
>>
>> Exactly, and the same happens with glibc.  When you use -std=c*, that means you are declaring strict ISO C, and all extensions are disabled by > default unless explicitly enabled (e.g. with -D_POSIX_C_SOURCE=200112L).
> 
>>  If you are not compatible with ISO C, then you should be using
>> -std=gnu* instead.
>>
>> --
>> Yaakov
>>
>> --
> 
> Many thanks for the info, Yaakov. Accoring to the manual -std determines the language standard and c11 means ISO C11, the 2011 revision of the ISO C standard. Howevery, I find no restriction on POSIX in ISO/IEC 9899:2011. So why should -std=c11 have an influence on Pthreads? Am I missing something?

The option means explicit standard C without extensions or additions.
POSIX is atop of the C standard and requires specific definition by the
user if it's required.

-- 
cyg Simple

--
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Pthreads: Prototypes missing if -std=c11
  2017-07-13 15:36 Pthreads: Prototypes missing if -std=c11 bz0815
  2017-07-13 17:38 ` cyg Simple
@ 2017-07-13 19:30 ` Brian Inglis
  1 sibling, 0 replies; 5+ messages in thread
From: Brian Inglis @ 2017-07-13 19:30 UTC (permalink / raw)
  To: cygwin

On 2017-07-13 09:36, bz0815@tirol.com wrote:
>> On 2017-07-12 11:15, bz0815@tirol.com wrote:
>>> gcc does not recognize some functions from pthread.h if option -std=c11
>>> is used:
>>
>> Exactly, and the same happens with glibc. When you use -std=c*, that means 
>> you are declaring strict ISO C, and all extensions are disabled by default 
>> unless explicitly enabled (e.g. with -D_POSIX_C_SOURCE=200112L).
>> 
>>  If you are not compatible with ISO C, then you should be using
>> -std=gnu* instead.

> Many thanks for the info, Yaakov. Accoring to the manual -std determines the 
> language standard and c11 means ISO C11, the 2011 revision of the ISO C 
> standard. Howevery, I find no restriction on POSIX in ISO/IEC 9899:2011. So
> why should -std=c11 have an influence on Pthreads? Am I missing something?
ISO/IEC 9899 specifies the features and facilities that shall or may be provided
by all standard conforming freestanding or hosted implementations. It considers
proposals from stakeholders for new language and library features based on
available implementations.

Threading is optional in standards conforming implementations: conforming
programs must compile cleanly if the feature is not available, and use only the
facilities declared in threads.h.
See https://en.wikipedia.org/wiki/C11_(C_standard_revision)#Optional_features

POSIX specifies common features and facilities that shall or may be provided by
one class of hosted implementations, with additional requirements to those
specified for standard conforming implementations.

POSIX does not provide threads.h but does provide pthreads.h, so you have a
choice, depending on whether you want to be strictly conforming or support POSIX.

See or search for Linux glibc man 7 feature_test_macros for more info about
macros and values.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Pthreads: Prototypes missing if -std=c11
  2017-07-12 16:16 bz0815
@ 2017-07-12 17:50 ` Yaakov Selkowitz
  0 siblings, 0 replies; 5+ messages in thread
From: Yaakov Selkowitz @ 2017-07-12 17:50 UTC (permalink / raw)
  To: cygwin

On 2017-07-12 11:15, bz0815@tirol.com wrote:
> gcc does not recognize some functions from pthread.h if option -std=c11 is used:

Exactly, and the same happens with glibc.  When you use -std=c*, that
means you are declaring strict ISO C, and all extensions are disabled by
default unless explicitly enabled (e.g. with -D_POSIX_C_SOURCE=200112L).
 If you are not compatible with ISO C, then you should be using
-std=gnu* instead.

-- 
Yaakov

--
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Pthreads: Prototypes missing if -std=c11 
@ 2017-07-12 16:16 bz0815
  2017-07-12 17:50 ` Yaakov Selkowitz
  0 siblings, 1 reply; 5+ messages in thread
From: bz0815 @ 2017-07-12 16:16 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-07-13 19:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-13 15:36 Pthreads: Prototypes missing if -std=c11 bz0815
2017-07-13 17:38 ` cyg Simple
2017-07-13 19:30 ` Brian Inglis
  -- strict thread matches above, loose matches on Subject: below --
2017-07-12 16:16 bz0815
2017-07-12 17:50 ` Yaakov Selkowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).