<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:"Book Antiqua";
panose-1:2 4 6 2 5 3 5 3 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.im
{mso-style-name:im;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Book Antiqua","serif";
color:#1F497D;}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";
mso-fareast-language:EN-IE;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-IE link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D'>Hmm! In order for it to matter, the program would have to do:<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New";color:black'> #include <math.h><o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New";color:black'> #include <cmath><o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D'>which I think is unlikely, but:<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New";color:black'> #include <math.h><o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New";color:black'> #include “otherfile.h”<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D'>where ‘</span><span style='font-family:"Courier New";color:black'>otherfile.h</span><span style='font-family:"Book Antiqua","serif";color:#1F497D'>’ then includes ‘</span><span style='font-family:"Courier New";color:black'><cmath></span><span style='font-family:"Book Antiqua","serif";color:#1F497D'>’, which is more likely to happen when ‘</span><span style='font-family:"Courier New";color:black'><cmath></span><span style='font-family:"Book Antiqua","serif";color:#1F497D'>’ is included by proxy after ‘</span><span style='font-family:"Courier New";color:#1F497D'><math.h></span><span style='font-family:"Book Antiqua","serif";color:#1F497D'>’. But you are correct, I hadn’t thought of this and the pattern would need to be refined to address this. I did not come across this scenario in the LibC++ test-suite or my own.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D'>Thanks,<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D'> MartinO<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua","serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> James Y Knight [mailto:jyknight@google.com] <br><b>Sent:</b> 27 January 2016 15:29<br><b>To:</b> Martin J. O'Riordan<br><b>Cc:</b> David Chisnall; Clang Dev<br><b>Subject:</b> Re: [cfe-dev] LibC++ v3.8 - Problems with ISO C wrapper headers<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>This doesn't seem right -- won't it break code that does this:<o:p></o:p></p><div><div><p class=MsoNormal>#include <math.h><o:p></o:p></p></div></div><div><div><p class=MsoNormal>#include <cmath><o:p></o:p></p></div></div><div><p class=MsoNormal>? (since the "<span style='font-size:9.5pt'>#ifdef _LIBCPP_INCLUDING_STDC_HEADER"</span> is within the "#ifndef _LIBCPP_MATH_H" block, and thus only gets checked once)<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div></div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On Wed, Jan 27, 2016 at 10:22 AM, Martin J. O'Riordan via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>I suppose I am more focussed on embedded systems than hosted - thus the reference to 'newlib'; and I'm sure that there are many alternative STDC libraries that I have never heard of. But I think that the LibC++ wrapper headers is still a good place to abstract such portability issues so that users of LibC++ are unaware of the ISO C header implementation that lies beneath.<br><br><br>I have also attached a patch file computed against the #258931 revision on:<br><br> <a href="https://llvm.org/svn/llvm-project/libcxx/branches/release_38/include" target="_blank">https://llvm.org/svn/llvm-project/libcxx/branches/release_38/include</a><br><br>Although many files have changed, the nature of the changes is quite simple.<br><br> o In each of the '<cXXXX>' files I have inserted:<br><br> #define _LIBCPP_INCLUDING_STDC_HEADER<br><br> before each '#include <####.h>' ISO C header, and followed by:<br><br> #undef _LIBCPP_INCLUDING_STDC_HEADER<br><br> I have done this for all LibC++ headers that include an ISO C header even if<br> it does not refer to a LibC++ wrapping header, in case one C header<br> includes another in any particular ISO C header implementation.<br><br> o In each of the '<XXXX.h>' ISO C header wrappers, where appropriate I have<br> replaced:<br><br> #ifdef __cplusplus<br> ...<br> #endif // __cplusplus<br><br> with:<br><br> #ifdef _LIBCPP_INCLUDING_STDC_HEADER<br> ...<br> #endif // _LIBCPP_INCLUDING_STDC_HEADER<br><br> o Before the C++ overloaded functions are introduced at global scope, I have<br> inserted:<br><br> _LIBCPP_BEGIN_NAMESPACE_STD<br><br> and afterwards:<br><br> _LIBCPP_END_NAMESPACE_STD<br><br> o Finally, in '<math.h>' in particular, I have prefixed the forwarded<br> names with '::' since at this point in the 'using ::name;' has not yet<br> been seen.<br><br>The patch is a suggestion, and the '_LIBCPP_INCLUDING_STDC_HEADER' name I picked are just my idea for following the existing convention used by the LibC++ maintainers.<br><br><span class=im> MartinO</span><br><br><span class=im>-----Original Message-----</span><br><span class=im>From: Dr D. Chisnall [mailto:<a href="mailto:dc552@hermes.cam.ac.uk">dc552@hermes.cam.ac.uk</a>] On Behalf Of David Chisnall</span><br><span class=im>Sent: 27 January 2016 9:25</span><br><span class=im>To: <a href="mailto:Martin.ORiordan@Movidius.com">Martin.ORiordan@Movidius.com</a></span><br><span class=im>Cc: Craig, Ben; Clang Dev</span><br><span class=im>Subject: Re: [cfe-dev] LibC++ v3.8 - Problems with ISO C wrapper headers</span><o:p></o:p></p><div><div><p class=MsoNormal>On 26 Jan 2016, at 20:09, Martin J. O'Riordan via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>><br>> And C++ also requires that some parts of the interfaces from C are presented to C++ as functions - examples being ‘fpclassify’, ‘signbit’ etc. These have to be handled differently, and I think that the current LibC++ approach to these is good and maintains semantic compatibility with C.<br>><br>> I had intended to build a patch file of my changes today in case anyone is interested, but other things got me busy. I’ll do that tomorrow and attach it to this thread.<br>><br>> I think that it is a good idea to have LibC++ provide its own wrapper headers for the C headers. It is a logical place to deal with portability issues that arise when referring to C headers provided by newlib, uclibc or glibc (and other less well known implementations). The handling of these portability issues will mean that the ‘c’ prefixed C++ headers will need little or no alteration and just maintain the ‘std’ namespace.<br>><br><br>I note that none of your listed libc implementations are the defaults on the operating systems that ship libc++ as the default C++ standard library implementation…<br><br>It would be very helpful for people who are working on this to provide a set of recommendations for C library maintainers to make C++ interoperability easier. That way, those of us who do have control over the libc headers can work from the other end to improve the situation.<br><br>David<o:p></o:p></p></div></div><p class=MsoNormal style='margin-bottom:12.0pt'><br>_______________________________________________<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" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>