<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hello,</div><div><br></div><div>While I was playing with the new clang module functionality, I encountered an issue with the 'convert #include in import' feature.</div><div><br></div><div>Apparently, when including a file using an absolute path, clang does not try at all to map it to possibly existing included module. It results in some inconsistencies when compiling with and without module enabled.</div><div><br></div><div>Take for instance this source file:</div><div><br></div><div>------------ include.c</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(209, 47, 27); "><span style="color: #78492a">#include </span>"/usr/include/stdio.h"</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; "><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(120, 73, 42); ">#include <span style="color: #d12f1b"><stdio.h></span></div></div><div><br></div><div>-------------------------</div><div><br></div><div>Obviously, as the stdio.h file contains include guards, this file compile fine without modules.</div><div>But if I enable modules, clang does not figures both includes points to the same files, and so the same module, and it try to import the module, while the stdio.h was already included.</div><div>And it result in a rather ugly mess:</div><div><br></div><div>$ clang -fsyntax-only -fmodules include.c</div><div><br></div><div>usr/include/stdio.h:96:8: error: redefinition of '__sbuf'</div><div>struct __sbuf {</div><div> ^</div><div>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/stdio.h:86:8: note: previous definition is here</div><div>struct __sbuf {</div><div> ^</div><div>In file included from include.c:2:</div><div>/usr/include/stdio.h:130:16: error: redefinition of '__sFILE'</div><div>typedef struct __sFILE {</div><div> ^</div><div>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/stdio.h:120:16: note: previous definition is here</div><div>typedef struct __sFILE {</div><div> ^</div><div><br></div><div>… and so on, on many lines.</div><div><br></div><div>Of course, I don't expect someone write this kind of include, but this is what Xcode and clang synthesize when using prefix headers.</div><div>Xcode convert the header path to an absolute path, and pass it to clang using the "-include" parameter.</div><div>Then clang interpret the '-include' argument as an #include directive, and try to import the file using the absolute path.</div><div><br></div><div>Is this a clang bug, or is it an expected behaviors for the modules ? If this is a bug, I'd be glad to have a look at what is wrong, and propose patches.</div><div><br></div><div>
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; "><div>-- Jean-Daniel</div><div><br></div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br></body></html>