<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Hi Florian</div><div class="gmail_quote"> </div><div class="gmail_quote">On Tue, Oct 15, 2013 at 9:34 AM, Florian Kutscherauer <span dir="ltr"><<a href="mailto:florian.kutscherauer@gmx.at" target="_blank">florian.kutscherauer@gmx.at</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">Dear developers,<br>
<br>
<br>
I'm new to LLVM, so please don't bite off my head if this is a dumb question.<br>
<br>
I've noticed that some of the C++ files (both headers and bodies) include C-headers, like <stddef.h>, <assert.h> etc., while others use the corresponding C++-headers, like <cstddef>, <cassert>, and so on.<br>
<br>
So, I was wondering the reason for that might be: Is this just out of habit and custom, or is there more to it?<br>
<br>
<br>
Best regards,<br>
<br>
Flo.<br></blockquote><div> </div><div><div>I think in general you'd want to use the C++ headers, not the C headers I.e. prefer cstdio over stdio.h.</div><div>One exception is when coding inside of libcxx itself (as opposed to using it). There you are usually implementing the C++ header itself and including the C header is often the necessary thing to do for one reason or another. Sometimes though it might be it's own C++ header that it needs to reference depending on the case in question.</div>
<div>You might of course want to reference the C header if the header file is going to be compiled by a C compiler instead of a C++ one.</div><div> </div><div>Generally it's quite a common case is that people use the C headers in C++ by mistake or occasionally because of some compatibility problem they are trying to avoid. The Ninja project is one where I see a lot of C references that I think could be changed to C++ but that was actively refused when I suggested it. So I don't know all the reasons why people do this but it's quite common. I'd generally stick to the rule if your code is in a c++ program and you're not aware of any problem or trying to share the header with a C program, use the C++ headers, sometimes they provide useful overloads of similar functions in the C headers. Sometimes they can conflict too (he says with one such example in mind, coming to a forum near you soon lol)</div>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"> </blockquote></div></div></div>