public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Weird mismatch between cdefs and stdatomic
@ 2019-01-28 14:02 LRN
  2019-01-30  7:16 ` LRN
  0 siblings, 1 reply; 3+ messages in thread
From: LRN @ 2019-01-28 14:02 UTC (permalink / raw)
  To: cygwin


[-- Attachment #1.1: Type: text/plain, Size: 826 bytes --]

This[0] and this[1]. One header checks for atomic C/CXX extensions *and* for
the presence of a C++ compiler, while the other only checks for extensions.

The result is that the _Atomic() macro is *not* defined in cdefs.h when
compiled with C++, but the stdatomic.h atomic macros assume that it is, and try
to access the "__val" struct member, with predictable and sad results.

I just stumbled upon this while compiling OpenSSL, and wanted to see if anyone
else encountered this problem.

[0]
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=newlib/libc/include/stdatomic.h;h=09c0cf73e0036537f54c6f5b86d854d1e77795b3;hb=HEAD#l36
[1]
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=newlib/libc/include/sys/cdefs.h;h=ccb47ea4045d025b2ccd2319720879c5f37b3c0f;hb=HEAD#l290




[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: Weird mismatch between cdefs and stdatomic
  2019-01-28 14:02 Weird mismatch between cdefs and stdatomic LRN
@ 2019-01-30  7:16 ` LRN
  2019-01-30  8:00   ` Brian Inglis
  0 siblings, 1 reply; 3+ messages in thread
From: LRN @ 2019-01-30  7:16 UTC (permalink / raw)
  To: cygwin


[-- Attachment #1.1: Type: text/plain, Size: 818 bytes --]

On 28.01.2019 17:02, LRN wrote:
> This[0] and this[1]. One header checks for atomic C/CXX extensions *and* for
> the presence of a C++ compiler, while the other only checks for extensions.
> 
> The result is that the _Atomic() macro is *not* defined in cdefs.h when
> compiled with C++, but the stdatomic.h atomic macros assume that it is, and try
> to access the "__val" struct member, with predictable and sad results.
> 
> I just stumbled upon this while compiling OpenSSL, and wanted to see if anyone
> else encountered this problem.
> 

There is also a "!defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L"
condition in cdefs.h that is not reproduced in stdatomic.h. So my initial guess
seems to have been incorrect - it's not about C vs C++ compiler, it's about C11
vs C99 compiler modes.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: Weird mismatch between cdefs and stdatomic
  2019-01-30  7:16 ` LRN
@ 2019-01-30  8:00   ` Brian Inglis
  0 siblings, 0 replies; 3+ messages in thread
From: Brian Inglis @ 2019-01-30  8:00 UTC (permalink / raw)
  To: cygwin

On 2019-01-30 00:15, LRN wrote:
> On 28.01.2019 17:02, LRN wrote:
>> This[0] and this[1]. One header checks for atomic C/CXX extensions *and* for
>> the presence of a C++ compiler, while the other only checks for extensions.
>> The result is that the _Atomic() macro is *not* defined in cdefs.h when
>> compiled with C++, but the stdatomic.h atomic macros assume that it is, and try
>> to access the "__val" struct member, with predictable and sad results.
>> I just stumbled upon this while compiling OpenSSL, and wanted to see if anyone
>> else encountered this problem.
> There is also a "!defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L"
> condition in cdefs.h that is not reproduced in stdatomic.h. So my initial guess
> seems to have been incorrect - it's not about C vs C++ compiler, it's about C11
> vs C99 compiler modes.

Search or man feature_test_macros or look at

	https://sourceforge.net/p/predef/wiki/Standards/

and for idiosyncracies

	https://sourceforge.net/p/predef/wiki/Compilers/

as of two years ago on the wiki; the downloads are six years old; for Windows see

	https://docs.microsoft.com/en-us/cpp/visual-cpp-language-conformance

as MS VC slowly moves towards C99 and C11 support for C++11 and C++14
conformance; details below

	https://social.msdn.microsoft.com/search/en-US/feed?query=conformance&rn=Visual%20C%2b%2b%20Team%20Blog&rq=site%3ahttps%3a%2f%2fblogs.msdn.microsoft.com%2fvcblog&format=RSS

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

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

--
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] 3+ messages in thread

end of thread, other threads:[~2019-01-30  8:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-28 14:02 Weird mismatch between cdefs and stdatomic LRN
2019-01-30  7:16 ` LRN
2019-01-30  8:00   ` Brian Inglis

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