<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi,</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Thanks for your answer. It helped me a lot. Indeed by looking at the code this part of clang looks very complicated.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Actually I found another way of doing what I wanted to do.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Cheers,</div><div id="AppleMailSignature">Julien<br><br></div><div><br>On 14 Mar 2017, at 13:01, mats petersson <<a href="mailto:mats@planetcatfish.com">mats@planetcatfish.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div><div><div>It's not entirely clear what you are asking - the full answer to your question would probably take a few days to write down with sufficient precision to explain "everything that happens due to #include "foo.h" inside clang. So if my explanation below isn't "enough", please provide a more specific follow-up question - I'm not sure I can give the answer, because what I've explained is nearly the full extent of my knowledge...<br><br>Clang doesn't use a traditional pre-processor (as per the "old school C compiler", where you'd get a "foo.i" file of the preprocessed input), instead it parses and understand preprocessor directives in the main processing of the file. It has code that understands the file-structure of the overall compilation unit. [Whether it's a "user" or "system" include is not really important, except for a few cases of "if it's a system include don't issue warnings for <something that is considered harmless but sometimes 'wrong' in system headers)],<br><br></div>This comment in include/clang/Lex/Preprocessor.h explains the same thing I just said:<br>/// Lexers know only about tokens within a single source file, and don't<br>/// know anything about preprocessor-level issues like the \#include stack,<br>/// token expansion, etc.<br>class Preprocessor : public RefCountedBase<Preprocessor> <br><br></div>The Preprocessor class is used to "help" with the task of dealing with this. To the "compiler proper", it will seem like all the input came from a single file.<br><br>--<br></div>Mats<br><div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 14 March 2017 at 09:17, via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm looking at the clang source code and I'm wandering where clang handle the include from users.<br>
<br>
If you have a simple C file foo.c:<br>
<br>
#include <stdio.h><br>
#include "foo.h"<br>
<br>
void foo(void) {<br>
  printf("foo\n");<br>
}<br>
<br>
int main(void) {<br>
  foo();<br>
  return 0;<br>
}<br>
<br>
and the corresponding foo.h header:<br>
<br>
void foo(void);<br>
<br>
Which part of clang "merge" (or inline) foo.c and foo.h together? If I understand well that is what is happening, right?<br>
<br>
Thank you for your answers!<br>
<br>
Cheers,<br>
Julien<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">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>
</blockquote></div><br></div>
</div></blockquote></body></html>