Changeset 38824 in webkit


Ignore:
Timestamp:
Nov 27, 2008 5:43:51 PM (15 years ago)
Author:
jchaffraix@webkit.org
Message:

2008-11-27 Julien Chaffraix <jchaffraix@webkit.org>

Reviewed by Eric Seidel.

Bug 22468: Coding style: config.h should only be included in implementation files, not in header
https://bugs.webkit.org/show_bug.cgi?id=22468

Clarified the rules about config.h inclusion and added 2 new examples to illustrate it. Also
added an explanation about the implementation files.

  • coding/coding-style.html:
Location:
trunk/WebKitSite
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitSite/ChangeLog

    r38760 r38824  
     12008-11-27  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Bug 22468: Coding style: config.h should only be included in implementation files, not in header
     6        https://bugs.webkit.org/show_bug.cgi?id=22468
     7
     8        Clarified the rules about config.h inclusion and added 2 new examples to illustrate it. Also
     9        added an explanation about the implementation files.
     10
     11        * coding/coding-style.html:
     12
    1132008-11-25  Dean Jackson  <dino@apple.com>
    214
  • trunk/WebKitSite/coding/coding-style.html

    r38539 r38824  
    7070</li>
    7171
    72 <li>In an implementation file, code inside a namespace should <em>not</em> be indented.
     72<li>In an implementation file (files with the extension .cpp, .c or .mm), code inside a namespace should <em>not</em> be indented.
    7373<h4 class="right">Right:</h4>
    7474<pre class="code">
     
    599599<ol>
    600600
    601 <li>All files must #include "config.h" first.
    602 
    603 <li>All files must #include the primary header second, just after "config.h".
    604 So for example, Node.cpp should include Node.h first, before other files.
    605 This guarantees that each header's completeness is tested, to make sure it
    606 can be compiled without requiring any other header files be included first.
     601<li>All implementation files must #include "config.h" first. Header
     602files should never include "config.h".
     603
     604<h4 class="right">Right:</h4>
     605<pre class="code">
     606// RenderLayer.h
     607#include "Node.h"
     608#include "RenderObject.h"
     609#include "RenderView.h"
     610</pre>
     611
     612<h4 class="wrong">Wrong:</h4>
     613<pre class="code">
     614// RenderLayer.h
     615#include "config.h"
     616
     617#include "RenderObject.h"
     618#include "RenderView.h"
     619#include "Node.h"
     620</pre>
     621
     622<li>All implementation files must #include the primary header second,
     623just after "config.h". So for example, Node.cpp should include Node.h first,
     624before other files. This guarantees that each header's completeness is tested.
     625This also assures that each header can be compiled without requiring any other
     626header files be included first.
    607627
    608628<li>Other #include statements should be in sorted order (case sensitive, as
     
    610630Don't bother to organize them in a logical order.
    611631
     632<h4 class="right">Right:</h4>
     633<pre class="code">
     634// HTMLDivElement.cpp
     635#include "config.h"
     636#include "HTMLDivElement.h"
     637
     638#include "Attribute.h"
     639#include "HTMLElement.h"
     640#include "QualifiedName.h"
     641
     642</pre>
     643
     644<h4 class="wrong">Wrong:</h4>
     645<pre class="code">
     646// HTMLDivElement.cpp
     647#include "HTMLElement.h"
     648#include "HTMLDivElement.h"
     649#include "QualifiedName.h"
     650#include "Attribute.h"
     651</pre>
     652
    612653</ol>
    613654
Note: See TracChangeset for help on using the changeset viewer.