<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">With the implementation I have in mind, you won’t be able to use C atomic types from C++ by default. But you should be able to define a macro and use C atomics from C++. It will prevent you from using C++ atomics though. The idea is to prevent mixing <atomic> and <stdatomic.h>, so only one of those should be included.<div class=""><br class=""></div><div class="">The plan is to allow to use C atomics from C++ but with minor hurdles so we'll guide people towards preferred approach C++ atomics from C++.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Volodymyr<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Mar 7, 2018, at 13:38, Jon Chesterfield via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="auto" class=""><div class="">It is occasionally necessary to write a C header that uses atomic types then include it in a C++ file. For example, implementing an abi defined in C using C++.</div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">This didn't quite work out of the box - I think I needed to #include <atomic> inside extern "C" or some similar absurdity - but I did get valid asm out of the result without modifying clang. Sadly I can't currently access the source to check the details.</div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">If this change goes ahead, would I no longer be able to use atomic types from a C header in C++?</div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">Cheers!</div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">Jon<br class=""><div class="gmail_extra" dir="auto"><br class=""><div class="gmail_quote">On 7 Mar 2018 16:15, "via cfe-dev" <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:<br type="attribution" class=""><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send cfe-dev mailing list submissions to<br class="">
<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">
<br class="">
To subscribe or unsubscribe via the World Wide Web, visit<br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/cfe-dev</a><br class="">
or, via email, send a message with subject or body 'help' to<br class="">
<a href="mailto:cfe-dev-request@lists.llvm.org" class="">cfe-dev-request@lists.llvm.org</a><br class="">
<br class="">
You can reach the person managing the list at<br class="">
<a href="mailto:cfe-dev-owner@lists.llvm.org" class="">cfe-dev-owner@lists.llvm.org</a><br class="">
<br class="">
When replying, please edit your Subject line so it is more specific<br class="">
than "Re: Contents of cfe-dev digest..."<br class="">
<br class="">
<br class="">
Today's Topics:<br class="">
<br class="">
1. [RFC] Make <atomic> and <stdatomic.h> explicitly incompatible<br class="">
(Volodymyr Sapsai via cfe-dev)<br class="">
2. Re: [RFC] Make <atomic> and <stdatomic.h> explicitly<br class="">
incompatible (Shoaib Meenai via cfe-dev)<br class="">
<br class="">
<br class="">
------------------------------<wbr class="">------------------------------<wbr class="">----------<br class="">
<br class="">
Message: 1<br class="">
Date: Wed, 07 Mar 2018 12:32:05 -0800<br class="">
From: Volodymyr Sapsai via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
To: Clang Dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
Subject: [cfe-dev] [RFC] Make <atomic> and <stdatomic.h> explicitly<br class="">
incompatible<br class="">
Message-ID: <<a href="mailto:C1343C23-7BE7-43A2-95BC-239F410913D8@apple.com" class="">C1343C23-7BE7-43A2-95BC-<wbr class="">239F410913D8@apple.com</a>><br class="">
Content-Type: text/plain; charset="utf-8"<br class="">
<br class="">
Hello all,<br class="">
<br class="">
Currently atomics are available in C through <stdatomic.h> and in C++ through <atomic>. These headers have some common names, so using both of them in the same translation unit usually doesn’t work. The downside is that in some cases diagnostic can be overly verbose and overwhelming. For example, compiling just 2 lines<br class="">
<br class="">
#include <stdatomic.h><br class="">
#include <atomic><br class="">
<br class="">
results in 68 errors.<br class="">
<br class="">
I am proposing to make these headers explicitly incompatible, so we have just a single error telling so instead of multiple errors. What do you think?<br class="">
<br class="">
Alternative solution is to make these headers compatible. But the consensus seems to be that it’s not the right solution. See <a href="https://reviews.llvm.org/D26376" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/<wbr class="">D26376</a> <<a href="https://reviews.llvm.org/D26376" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/<wbr class="">D26376</a>> for more details. There is also a proposal P0943R0: Support C atomics in C++ <<a href="http://open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0943r0.html" rel="noreferrer" target="_blank" class="">http://open-std.org/jtc1/<wbr class="">sc22/wg21/docs/papers/2018/<wbr class="">p0943r0.html</a>>. As far as I can tell, my proposal doesn’t interfere with P0943R0 but will be obsolete if that proposal is accepted. Regardless of the future development I think it is still beneficial to have better diagnostics in the short term.<br class="">
<br class="">
I am not providing concrete implementation yet, at first I want to know the opinion of the community on the matter.<br class="">
<br class="">
Thanks,<br class="">
Volodymyr<br class="">
-------------- next part --------------<br class="">
An HTML attachment was scrubbed...<br class="">
URL: <<a href="http://lists.llvm.org/pipermail/cfe-dev/attachments/20180307/666af01c/attachment-0001.html" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/<wbr class="">pipermail/cfe-dev/attachments/<wbr class="">20180307/666af01c/attachment-<wbr class="">0001.html</a>><br class="">
<br class="">
------------------------------<br class="">
<br class="">
Message: 2<br class="">
Date: Wed, 7 Mar 2018 21:15:02 +0000<br class="">
From: Shoaib Meenai via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
To: Volodymyr Sapsai <<a href="mailto:vsapsai@apple.com" class="">vsapsai@apple.com</a>>, Clang Dev<br class="">
<<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
Subject: Re: [cfe-dev] [RFC] Make <atomic> and <stdatomic.h><br class="">
explicitly incompatible<br class="">
Message-ID: <<a href="mailto:43BFBEC0-0C03-4B7A-874F-62F562C9FDB5@fb.com" class="">43BFBEC0-0C03-4B7A-874F-<wbr class="">62F562C9FDB5@fb.com</a>><br class="">
Content-Type: text/plain; charset="utf-8"<br class="">
<br class="">
I'd be in favor of making them explicitly incompatible. I ran into this recently, found the incompatibility quite surprising, and had to do a bunch of research (looking at the relevant standards, doing experiments across a bunch of compilers and standard libraries, etc.) to convince myself that it was expected behavior. An explicit error would be super nice.<br class="">
<br class="">
From: cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org" class="">cfe-dev-bounces@lists.llvm.<wbr class="">org</a>> on behalf of cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
Reply-To: Volodymyr Sapsai <<a href="mailto:vsapsai@apple.com" class="">vsapsai@apple.com</a>><br class="">
Date: Wednesday, March 7, 2018 at 12:32 PM<br class="">
To: cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
Subject: [cfe-dev] [RFC] Make <atomic> and <stdatomic.h> explicitly incompatible<br class="">
<br class="">
Hello all,<br class="">
<br class="">
Currently atomics are available in C through <stdatomic.h> and in C++ through <atomic>. These headers have some common names, so using both of them in the same translation unit usually doesn’t work. The downside is that in some cases diagnostic can be overly verbose and overwhelming. For example, compiling just 2 lines<br class="">
<br class="">
#include <stdatomic.h><br class="">
#include <atomic><br class="">
<br class="">
results in 68 errors.<br class="">
<br class="">
I am proposing to make these headers explicitly incompatible, so we have just a single error telling so instead of multiple errors. What do you think?<br class="">
<br class="">
Alternative solution is to make these headers compatible. But the consensus seems to be that it’s not the right solution. See <a href="https://reviews.llvm.org/D26376" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/<wbr class="">D26376</a><<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D26376&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=f2XAChgmKGyURiNTGeNTF1t1Fpo5BLSqNdUKyYAZYeM&s=O1AIlpTPrgXe3-fXW3-VqVGTAUhg2qKBozM1iOtQhbE&e=" rel="noreferrer" target="_blank" class="">https://urldefense.<wbr class="">proofpoint.com/v2/url?u=https-<wbr class="">3A__reviews.llvm.org_D26376&d=<wbr class="">DwMFaQ&c=<wbr class="">5VD0RTtNlTh3ycd41b3MUw&r=<wbr class="">o3kDXzdBUE3ljQXKeTWOMw&m=<wbr class="">f2XAChgmKGyURiNTGeNTF1t1Fpo5BL<wbr class="">SqNdUKyYAZYeM&s=O1AIlpTPrgXe3-<wbr class="">fXW3-VqVGTAUhg2qKBozM1iOtQhbE&<wbr class="">e=</a>> for more details. There is also a proposal P0943R0: Support C atomics in C++<<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__open-2Dstd.org_jtc1_sc22_wg21_docs_papers_2018_p0943r0.html&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=f2XAChgmKGyURiNTGeNTF1t1Fpo5BLSqNdUKyYAZYeM&s=iHKcnTreK84QBWD-j_3_n7ww5ON1-EzKzni3NgSgiaY&e=" rel="noreferrer" target="_blank" class="">https://urldefense.<wbr class="">proofpoint.com/v2/url?u=http-<wbr class="">3A__open-2Dstd.org_jtc1_sc22_<wbr class="">wg21_docs_papers_2018_p0943r0.<wbr class="">html&d=DwMFaQ&c=<wbr class="">5VD0RTtNlTh3ycd41b3MUw&r=<wbr class="">o3kDXzdBUE3ljQXKeTWOMw&m=<wbr class="">f2XAChgmKGyURiNTGeNTF1t1Fpo5BL<wbr class="">SqNdUKyYAZYeM&s=<wbr class="">iHKcnTreK84QBWD-j_3_n7ww5ON1-<wbr class="">EzKzni3NgSgiaY&e=</a>>. As far as I can tell, my proposal doesn’t interfere with P0943R0 but will be obsolete if that proposal is accepted. Regardless of the future development I think it is still beneficial to have better diagnostics in the short term.<br class="">
<br class="">
I am not providing concrete implementation yet, at first I want to know the opinion of the community on the matter.<br class="">
<br class="">
Thanks,<br class="">
Volodymyr<br class="">
-------------- next part --------------<br class="">
An HTML attachment was scrubbed...<br class="">
URL: <<a href="http://lists.llvm.org/pipermail/cfe-dev/attachments/20180307/a2ab09a8/attachment.html" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/<wbr class="">pipermail/cfe-dev/attachments/<wbr class="">20180307/a2ab09a8/attachment.<wbr class="">html</a>><br class="">
<br class="">
------------------------------<br class="">
<br class="">
Subject: Digest Footer<br class="">
<br class="">
______________________________<wbr class="">_________________<br class="">
cfe-dev mailing list<br class="">
<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/cfe-dev</a><br class="">
<br class="">
<br class="">
------------------------------<br class="">
<br class="">
End of cfe-dev Digest, Vol 129, Issue 36<br class="">
******************************<wbr class="">**********<br class="">
</blockquote></div><br class=""></div></div></div>
_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></div></blockquote></div><br class=""></div></body></html>