<div dir="auto"><div>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"><br></div><div dir="auto">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"><br></div><div dir="auto">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"><br></div><div dir="auto">Cheers!</div><div dir="auto"><br></div><div dir="auto">Jon<br><div class="gmail_extra" dir="auto"><br><div class="gmail_quote">On 7 Mar 2018 16:15, "via cfe-dev" <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br type="attribution"><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>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:cfe-dev-request@lists.llvm.org">cfe-dev-request@lists.llvm.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:cfe-dev-owner@lists.llvm.org">cfe-dev-owner@lists.llvm.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of cfe-dev digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. [RFC] Make <atomic> and <stdatomic.h> explicitly incompatible<br>
(Volodymyr Sapsai via cfe-dev)<br>
2. Re: [RFC] Make <atomic> and <stdatomic.h> explicitly<br>
incompatible (Shoaib Meenai via cfe-dev)<br>
<br>
<br>
------------------------------<wbr>------------------------------<wbr>----------<br>
<br>
Message: 1<br>
Date: Wed, 07 Mar 2018 12:32:05 -0800<br>
From: Volodymyr Sapsai via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
To: Clang Dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
Subject: [cfe-dev] [RFC] Make <atomic> and <stdatomic.h> explicitly<br>
incompatible<br>
Message-ID: <<a href="mailto:C1343C23-7BE7-43A2-95BC-239F410913D8@apple.com">C1343C23-7BE7-43A2-95BC-<wbr>239F410913D8@apple.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hello all,<br>
<br>
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>
<br>
#include <stdatomic.h><br>
#include <atomic><br>
<br>
results in 68 errors.<br>
<br>
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>
<br>
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">https://reviews.llvm.org/<wbr>D26376</a> <<a href="https://reviews.llvm.org/D26376" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>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">http://open-std.org/jtc1/<wbr>sc22/wg21/docs/papers/2018/<wbr>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>
<br>
I am not providing concrete implementation yet, at first I want to know the opinion of the community on the matter.<br>
<br>
Thanks,<br>
Volodymyr<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.llvm.org/pipermail/cfe-dev/attachments/20180307/666af01c/attachment-0001.html" rel="noreferrer" target="_blank">http://lists.llvm.org/<wbr>pipermail/cfe-dev/attachments/<wbr>20180307/666af01c/attachment-<wbr>0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Wed, 7 Mar 2018 21:15:02 +0000<br>
From: Shoaib Meenai via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
To: Volodymyr Sapsai <<a href="mailto:vsapsai@apple.com">vsapsai@apple.com</a>>, Clang Dev<br>
<<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
Subject: Re: [cfe-dev] [RFC] Make <atomic> and <stdatomic.h><br>
explicitly incompatible<br>
Message-ID: <<a href="mailto:43BFBEC0-0C03-4B7A-874F-62F562C9FDB5@fb.com">43BFBEC0-0C03-4B7A-874F-<wbr>62F562C9FDB5@fb.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
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>
<br>
From: cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org">cfe-dev-bounces@lists.llvm.<wbr>org</a>> on behalf of cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
Reply-To: Volodymyr Sapsai <<a href="mailto:vsapsai@apple.com">vsapsai@apple.com</a>><br>
Date: Wednesday, March 7, 2018 at 12:32 PM<br>
To: cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
Subject: [cfe-dev] [RFC] Make <atomic> and <stdatomic.h> explicitly incompatible<br>
<br>
Hello all,<br>
<br>
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>
<br>
#include <stdatomic.h><br>
#include <atomic><br>
<br>
results in 68 errors.<br>
<br>
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>
<br>
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">https://reviews.llvm.org/<wbr>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">https://urldefense.<wbr>proofpoint.com/v2/url?u=https-<wbr>3A__reviews.llvm.org_D26376&d=<wbr>DwMFaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>f2XAChgmKGyURiNTGeNTF1t1Fpo5BL<wbr>SqNdUKyYAZYeM&s=O1AIlpTPrgXe3-<wbr>fXW3-VqVGTAUhg2qKBozM1iOtQhbE&<wbr>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">https://urldefense.<wbr>proofpoint.com/v2/url?u=http-<wbr>3A__open-2Dstd.org_jtc1_sc22_<wbr>wg21_docs_papers_2018_p0943r0.<wbr>html&d=DwMFaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>f2XAChgmKGyURiNTGeNTF1t1Fpo5BL<wbr>SqNdUKyYAZYeM&s=<wbr>iHKcnTreK84QBWD-j_3_n7ww5ON1-<wbr>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>
<br>
I am not providing concrete implementation yet, at first I want to know the opinion of the community on the matter.<br>
<br>
Thanks,<br>
Volodymyr<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.llvm.org/pipermail/cfe-dev/attachments/20180307/a2ab09a8/attachment.html" rel="noreferrer" target="_blank">http://lists.llvm.org/<wbr>pipermail/cfe-dev/attachments/<wbr>20180307/a2ab09a8/attachment.<wbr>html</a>><br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br>
<br>
------------------------------<br>
<br>
End of cfe-dev Digest, Vol 129, Issue 36<br>
******************************<wbr>**********<br>
</blockquote></div><br></div></div></div>