<div dir="ltr">I'm curious about this too -- not just precompiled headers, other Windows headers too.<div><br></div><div>From a header-sorting script we use in Chromium:</div><div><br></div><div><pre id="c1" class="" style="margin-top:0px;margin-bottom:0px;color:rgb(0,0,0);padding-top:0.5em;outline:none;font-size:medium;line-height:16.25px"><span class="" id="c1_46"><span class="" style="color:rgb(136,0,0)"> # The win32 api has all sorts of implicit include order dependencies :-/</span>
</span><span class="" id="c1_47"><span class="" style="color:rgb(136,0,0)"> # Give a few headers special sort keys that make sure they appear before all</span>
</span><span class="" id="c1_48"><span class="" style="color:rgb(136,0,0)"> # other headers.</span>
</span><span class="" id="c1_49"> <span class="" style="color:rgb(0,0,136)">if</span> line.startswith(<span class="" style="color:rgb(0,136,0)">'<windows.h>'</span>): <span class="" style="color:rgb(136,0,0)"># Must be before e.g. shellapi.h</span>
</span><span class="" id="c1_50"> <span class="" style="color:rgb(0,0,136)">return</span> <span class="" style="color:rgb(0,136,0)">'0'</span>
</span><span class="" id="c1_51"> <span class="" style="color:rgb(0,0,136)">if</span> line.startswith(<span class="" style="color:rgb(0,136,0)">'<atlbase.h>'</span>): <span class="" style="color:rgb(136,0,0)"># Must be before atlapp.h.</span>
</span><span class="" id="c1_52"> <span class="" style="color:rgb(0,0,136)">return</span> <span class="" style="color:rgb(0,136,0)">'1'</span> + line
</span><span class="" id="c1_53"> <span class="" style="color:rgb(0,0,136)">if</span> line.startswith(<span class="" style="color:rgb(0,136,0)">'<ole2.h>'</span>): <span class="" style="color:rgb(136,0,0)"># Must be before e.g. intshcut.h</span>
</span><span class="" id="c1_54"> <span class="" style="color:rgb(0,0,136)">return</span> <span class="" style="color:rgb(0,136,0)">'1'</span> + line
</span><span class="" id="c1_55"> <span class="" style="color:rgb(0,0,136)">if</span> line.startswith(<span class="" style="color:rgb(0,136,0)">'<unknwn.h>'</span>): <span class="" style="color:rgb(136,0,0)"># Must be before e.g. intshcut.h</span>
</span><span class="" id="c1_56"> <span class="" style="color:rgb(0,0,136)">return</span> <span class="" style="color:rgb(0,136,0)">'1'</span> + line</span></pre></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 6, 2015 at 1:17 PM, Jean-philippe Dufraigne 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"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">Hi Daniel,<div>Sorry, I sent the initial message to the wrong list.</div><div><br><div>When using pre-compiled header, the Main Header for the file will not be detected since the first header needs to be the precompiled header.</div><div><div><br></div><div>I was looking at fixing it, but I am not quite sure how to go fixing it?</div></div><div><br></div><div>This will result in the main header being moved.</div><div><br></div><div><div>Expected:</div><div>MyFile.cpp:</div><div><br></div><div> #include "stdafx.h"</div><div> #include "MyFile.h"</div><div> #include "AnotherHeader.h"</div><div><br></div><div>Actual:</div><div><div>MyFile.cpp:</div><div><br></div><div> #include "stdafx.h"</div><div> #include "AnotherHeader.h"</div><div> #include "MyFile.h"</div></div></div><div><br></div><div>This can be somewhat worked around by leaving a line after the Main Header.</div><div><br></div><div>Fix Option 1:</div><div>Add a new option: PercompiledHeaderRegEx, and if detected assign priority -1, and keep on looking for MainHeader (Not great since we use unsigned)</div><div><br></div><div>Fix Option 2:</div><div>Add a keyword that can be used instead of the regular expression to refer to the MainHeader. This way one can add a regular expression for the pre-compiled header priority 0, and one for MainHeader priority 1. Consider it main header if first header with category >= MainHeaderCategory.</div><div><br></div><div>Fix Option 3:</div><div>A better plan?</div><div><br></div><div>Do you have any thought on the problem?</div><div>Kind Regards,</div><div>Jean-Philippe.</div></div></div>
</div><br></div>
<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" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>