[webkit-dev] coding style of #include statements

Andras Becsi abecsi at inf.u-szeged.hu
Wed Nov 3 07:24:13 PDT 2010


Hi,

on the contrary, I think <...> is correct for WTF headers, because they 
are framework headers, and the include path where the WTF headers are, 
is added with -I, so the preprocessor will find them first. That's why 
almost all WTF includes use #include <...> (there are only ~20 occasions 
where "" is used for WTF headers, which is wrong in my opinion, but not 
a coding style issue).

The sentence in question should rather say something about <>-style and 
""-style header includes to avoid confusion.

That said, I think the correct order is:

#include "ArgumentEncoder.h"
#include "WorkItem.h"
#include <QApplication>
#include <QLocalServer>
#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>

because alphabetical order matters here.

BR,
Andras

On 11/03/2010 01:06 PM, Osztrogonac Csaba wrote:
> Hi,
>
> Now the second one is correct, because you should use angle
> brackets <...> for system headers, and quote marks "..." for
> non system headers. I think you should use "wtf/HashSet.h".
>
> It is important, because searches order is different with <...> and "...":
> http://gcc.gnu.org/onlinedocs/gcc-4.3.2//cpp/Include-Syntax.html#Include-Syntax
>
>
> #include <file>:
> 1.) -I ... directories
> 2.) -isystem .. directories
> 3.) standard system directories
>
> #include "file":
> 1.) in the directory containing the current file
> 2.) -iquote
> 2.) -I
> 3.) -isystem
> 4.) standard system directories
>
> br,
> Ossy
>
> Patrick Roland Gansterer írta:
>> Currently, the style guidelines specify "Includes of system headers must
>> come after includes of other headers. "
>> But what about WebKit headers in arrow brackets?
>>
>> What is the correct style:
>>
>> #include "ArgumentEncoder.h"
>> #include "WorkItem.h"
>> #include <wtf/HashSet.h>
>> #include <wtf/OwnPtr.h> #include <QApplication>
>> #include <QLocalServer>
>>
>> or
>> #include "ArgumentEncoder.h"
>> #include "WorkItem.h"
>> #include <QApplication>
>> #include <QLocalServer>
>> #include <wtf/HashSet.h>
>> #include <wtf/OwnPtr.h>
>> I prefere the first one because <wtf/*.h> aren't real system headers.
>>
>> - Patrick
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev



More information about the webkit-dev mailing list