OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / doc / api / coding-style.qdoc
1 /****************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Free Documentation License
11 **
12 ** Alternatively, this file may be used under the terms of the GNU Free
13 ** Documentation License version 1.3 as published by the Free Software
14 ** Foundation and appearing in the file included in the packaging of this
15 ** file.
16 **
17 ** If you have questions regarding the use of this file, please contact
18 ** Nokia at qt-info@nokia.com.
19 **
20 ****************************************************************************/
21
22 /*!
23
24     \contentspage{index.html}{Qt Creator}
25     \page coding-style.html
26
27     \title Qt Creator Coding Rules
28
29     \note This document is work in progress.
30
31     The coding rules aim to guide Qt Creator developers, to help them write
32     understandable and maintainable code, and to minimize confusion and surprises.
33
34     As usual, rules are not set in stone. If you have a good reason to break one,
35     do so. But first make sure that at least some other developers agree with you.
36
37     To contribute to the main Qt Creator source, you should comply to the
38     following rules:
39
40     \list
41         \o  The most important rule is: KISS (keep it short and simple). Always
42             choose the simpler implementation option over the more complicated one.
43             This makes maintenance a lot easier.
44         \o  Write good C++ code. That is, readable, well commented when necessary,
45             and object-oriented.
46         \o  Take advantage of Qt. Do not re-invent the wheel. Think about which parts
47             of your code are generic enough that they might be incorporated into
48             Qt instead of Qt Creator.
49         \o  Adapt the code to the existing structures in Qt Creator.
50             If you have improvement ideas, discuss them with other developers
51             before writing the code.
52         \o  Follow the guidelines in \l{Code Constructs}, \l{Formatting}, and
53             \l{Patterns and Practices}.
54         \o  Document interfaces. Right now we use qdoc, but changing to doxygen
55             is being considered.
56         \endlist
57
58
59     \section1 Submitting Code
60
61     To submit code to Qt, you must understand the tools and mechanics as well as
62     the philosophy behind Qt development. For more information about how to set up
63     the development environment for working on a Qt library and how to submit code
64     and documentation for inclusion to Qt, see
65     \l{http://qt.gitorious.org/qt/pages/QtContributionGuidelines}{Qt Contribution Guidelines}.
66
67     \section1 Binary and Source Compatibility
68
69     The following list describes how the releases are numbered and defines
70     \e {binary compatibility} and \e {source code compatibility} between
71     releases:
72
73     \list
74         \o  Qt Creator 2.0.0 is a \e {major release}, Qt Creator 2.1.0 is a \e {minor
75             release}, and Qt Creator 2.1.3 is a \e {patch release}.
76         \o  \e {Backward binary compatibility} means that code linked to an
77             earlier version of the library still works.
78         \o  \e {Forward binary compatibility} means that code linked to a
79             newer version of the library works with an older library.
80         \o  \e {Source code compatibility} means that code compiles without
81             modification.
82         \endlist
83
84     We do not currently guarantee API nor ABI
85     (\l{http://en.wikipedia.org/wiki/Application_binary_interface}{application binary interface})
86     compatibility between major releases.
87
88     However, we try to preserve compatibility between minor and patch releases,
89     as follows:
90
91     \list
92         \o  Preserve backward binary compatibility and backward source code
93             compatibility in minor releases.
94         \o  Preserve backward and forward binary compatibility and forward and
95             backward source code compatibility in patch releases:
96         \list
97             \o  Do not add or remove any public API (e.g. global functions,x
98                 public/protected/private methods).
99             \o  Do not reimplement methods (not even inlines,
100                 nor protected or private methods).
101             \o  Check
102                 \l {http://developer.qt.nokia.com/wiki/Binary_Compatibility_Workarounds}{Binary Compatibility Workarounds}
103                 for ways to preserve binary compatibility.
104         \endlist
105     \endlist
106
107     \note This is not yet mandatory.
108     For more information on binary compatibility, see
109     \l{http://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++}{Binary Compatibility Issues With C++}.
110
111     \section1 Code Constructs
112
113     Follow the guidelines for code constructs to make the code faster and
114     clearer. In addition, the guidelines allow you to take advantage of the strong
115     type checking in C++.
116
117     \list
118         \o  Prefer preincrement to postincrement whenever possible.
119             Preincrement is potentially faster than postincrement. Just
120             think about the obvious implementations of pre/post-increment. This
121             rule applies to decrement too:
122
123             \code
124             ++T;
125             --U;
126
127             -NOT-
128
129             T++;
130             U--;
131             \endcode
132
133         \o  Try to minimize evaluation of the same code over and over. This is
134             aimed especially at loops:
135
136             \code
137
138             Container::iterator end = large.end();
139             for (Container::iterator it = large.begin(); it != end; ++it) {
140                     ...;
141             }
142
143             -NOT-
144
145             for (Container::iterator it = large.begin();
146                  it != large.end(); ++it) {
147                     ...;
148             }
149             \endcode
150
151
152         \o  You can use the Qt \c foreach loop in non-time-critical code with a Qt
153             container. It is a nice way to keep line noise down and to give the
154             loop variable a proper name:
155
156             \code
157                 foreach (QWidget *widget, container)
158                     doSomething(widget);
159
160                 -NOT-
161
162                 Container::iterator end = container.end();
163                 for (Container::iterator it = container.begin(); it != end; ++it)
164                     doSomething(*it);
165             \endcode
166
167             Make the loop variable const, if possible. This might prevent
168             unnecessary detaching of shared data:
169
170             \code
171                 foreach (const QString &name, someListOfNames)
172                     doSomething(name);
173
174                 - NOT -
175
176                 foreach (QString name, someListOfNames)
177                     doSomething(name);
178             \endcode
179
180         \endlist
181
182     \section1 Formatting
183
184     \section2 Capitalizing Identifiers
185
186     Use \l{http://en.wikipedia.org/wiki/CamelCase}{camel case} in identifiers.
187
188     Capitalize the first word in an identifier as follows:
189
190     \list
191         \o  Class names begin with a capital letter.
192         \o  Function names begin with a lower case letter.
193         \o  Variable names begin with a lower case letter.
194         \o  Enum names begin with a capital letter. Enum values use lower case and
195             contain some part of the name of the enum type.
196     \endlist
197
198     \section2 Whitespace
199
200     \list
201         \o  Use four spaces for indentation, no tabs.
202         \o  Use blank lines to group statements together where suited.
203         \o  Always use only one blank line.
204     \endlist
205
206     \section3 Pointers and References
207
208     For pointers or references, always use a single space before an asterisk (*)
209     or an ampersand (&), but never after.
210     Avoid C-style casts when possible:
211
212     \code
213     char *blockOfMemory = (char *)malloc(data.size());
214     char *blockOfMemory = reinterpret_cast<char *>(malloc(data.size()));
215
216     -NOT-
217
218     char* blockOfMemory = (char* ) malloc(data.size());
219     \endcode
220
221     Of course, in this particulare case, using \c new might be an even better
222     option.
223
224     \section3  Operator Names and Parentheses
225
226     Do not use spaces between operator names and function names. The equation
227     marks (==) are a part of the function name, and therefore, spaces make the
228     declaration look like an expression:
229
230     \code
231     operator==(type)
232
233     -NOT-
234
235     operator == (type)
236     \endcode
237
238     \section3 Function Names and Parentheses
239
240     Do not use spaces between function names and parentheses:
241
242     \code
243     void mangle()
244
245     -NOT-
246
247     void mangle ()
248     \endcode
249
250     \section3 Keywords
251
252     Always use a single space after a keyword, and before a curly brace:
253
254     \code
255     if (foo) {
256     }
257
258     -NOT-
259
260     if(foo){
261     }
262     \endcode
263
264     \section2 Braces
265
266     As a base rule, place the left curly brace on the same line as the
267     start of the statement:
268
269     \code
270     if (codec) {
271     }
272
273     -NOT-
274
275     if (codec)
276     {
277     }
278     \endcode
279
280     Exception: Function implementations and class declarations always have
281     the left brace in the beginning of a line:
282
283     \code
284     static void foo(int g)
285     {
286         qDebug("foo: %i", g);
287     }
288
289     class Moo
290     {
291     };
292     \endcode
293
294     Use curly braces when the body of a conditional statement contains more
295     than one line, and also if a single line statement is somewhat complex.
296     Otherwise, omit them:
297
298     \code
299     if (address.isEmpty())
300         return false;
301
302     for (int i = 0; i < 10; ++i)
303         qDebug("%i", i);
304
305     -NOT-
306
307     if (address.isEmpty()) {
308         return false;
309     }
310
311     for (int i = 0; i < 10; ++i) {
312         qDebug("%i", i);
313     }
314     \endcode
315
316     Exception 1: Use braces also if the parent statement covers several
317     lines or if it wraps:
318
319     \code
320     if (address.isEmpty()
321             || !isValid()
322             || !codec) {
323         return false;
324     }
325     \endcode
326
327     \note This could be re-written as:
328
329     \code
330     if (address.isEmpty())
331         return false;
332
333     if (!isValid())
334         return false;
335
336     if (!codec)
337         return false;
338     \endcode
339
340     Exception 2: Use braces also in if-then-else blocks where either the
341     if-code or the else-code covers several lines:
342
343     \code
344     if (address.isEmpty()) {
345         --it;
346     } else {
347         qDebug("%s", qPrintable(address));
348         ++it;
349     }
350
351     -NOT-
352
353     if (address.isEmpty())
354         --it;
355     else {
356         qDebug("%s", qPrintable(address));
357         ++it;
358     }
359     \endcode
360
361     \code
362     if (a) {
363         if (b)
364             ...
365         else
366             ...
367     }
368
369     -NOT-
370
371     if (a)
372         if (b)
373             ...
374         else
375             ...
376     \endcode
377
378     Use curly braces when the body of a conditional statement is empty:
379
380     \code
381     while (a) {}
382
383     -NOT-
384
385     while (a);
386     \endcode
387
388     \section2 Parentheses
389
390     Use parentheses to group expressions:
391
392     \code
393     if ((a && b) || c)
394
395     -NOT-
396
397     if (a && b || c)
398     \endcode
399
400     \code
401     (a + b) & c
402
403     -NOT-
404
405     a + b & c
406     \endcode
407
408     \section2 Line Breaks
409
410     \list
411         \o  Keep lines shorter than 100 characters.
412         \o  Insert line breaks if necessary.
413         \o  Commas go at the end of a broken line.
414         \o  Operators start at the beginning of the new line.
415             \code
416             if (longExpression
417                 || otherLongExpression
418                 || otherOtherLongExpression) {
419             }
420
421             -NOT-
422
423             if (longExpression ||
424                 otherLongExpression ||
425                 otherOtherLongExpression) {
426             }
427             \endcode
428     \endlist
429
430     \section2 Declarations
431
432     \list
433         \o  Use this order for the access sections of your class: public,
434             protected, private. The public section is interesting for every
435             user of the class. The private section is only of interest for the
436             implementors of the class (you).
437         \o  Avoid declaring global objects in the declaration file of the class.
438             If the same variable is used for all objects, use a static member.
439     \endlist
440
441     \section3 Declaring Variables
442
443     \list
444         \o  Avoid global or static variables.
445         \o  Avoid short names (such as, a, rbarr, nughdeget) whenever possible.
446             Use single-character variable names only for counters and
447             temporaries, where the purpose of the variable is obvious.
448         \o  Declare each variable on a separate line:
449             \code
450             QString a = "Joe";
451             QString b = "Foo";
452
453             -NOT-
454
455             QString a = "Joe", b = "Foo";
456             \endcode
457
458             \note \c{QString a = "Joe"} formally calls a copy constructor on a
459             temporary that is constructed from a string literal. Therefore, it is
460             potentially more expensive than direct construction by
461             \c {QString a("Joe")}. However, the compiler is allowed to elide the
462             copy (even if this has side effects), and modern compilers typically do
463             so. Given these equal costs, Qt Creator code favours the '=' idiom as
464             it is in
465             line with the traditional C-style initialization, it cannot be
466             mistaken as function declaration, and it reduces the level of nested
467             parantheses in more initializations.
468
469         \o  Avoid abbreviations:
470
471             \code
472             int height;
473             int width;
474             char *nameOfThis;
475             char *nameOfThat;
476
477             -NOT-
478
479             int a, b;
480             char *c, *d;
481             \endcode
482
483         \o  Wait with declaring a variable until it is needed. This is especially
484             important when initialization is done at the same time.
485     \endlist
486
487     \section1 Patterns and Practices
488
489     \section2 Passing File Names
490
491     Qt Creator API expects file names in portable format, that is, with slashes (/)
492     instead of backslashes (\\) even on Windows. To pass a file name from the user
493     to the API, convert it with QDir::fromNativeSeparators first. To present a file
494     name to the user, convert it back to native format with
495     QDir::toNativeSeparators.
496
497     When comparing file names, consider using FileManager::fixFileName which
498     makes sure that paths are clean and absolute and also takes Windows
499     case-insensitivity into account (even if it is an expensive operation).
500
501     \section2 Plugin Extension Points
502
503     A plugin extension point is an interface that is provided by one plugin
504     to be implemented by others. The plugin then retrieves all
505     implementations of the interface and uses them. That is, they \e extend the
506     functionality of the plugin. Typically, the
507     implementations of the interface are put into the global object pool
508     during plugin initialization, and the plugin retrieves them from the
509     object pool at the end of plugin initialization.
510
511     For example, the Find plugin provides the FindFilter interface for
512     other plugins to implement. With the FindFilter interface, additional search
513     scopes can be added, that appear in the \gui {Advanced Search} dialog. The
514     Find plugin retrieves all FindFilter implementations from the global
515     object pool and presents them in the dialog. The plugin forwards the
516     actual search request to the correct FindFilter implementation, which
517     then performs the search.
518
519     \section2 Using the Global Object Pool
520
521     You can add objects to the global object pool via
522     \l{ExtensionSystem::PluginManager::addObject()}, and retrieve objects
523     of a specific type again via
524     \l{ExtensionSystem::PluginManager::getObjects()}.  This should mostly
525     be used for implementations of \l{Plugin Extension Points}.
526
527     \note Do not put a singleton into the pool, and do not retrieve
528     it from there. Use the singleton pattern instead.
529
530     \section2 C++ Features
531
532     \list
533         \o  Do not use exceptions, unless you know what you do.
534         \o  Do not use RTTI (Run-Time Type Information; that is, the typeinfo
535             struct, the dynamic_cast or the typeid operators, including throwing
536             exceptions), unless you know what you do.
537         \o  Use templates wisely, not just because you can.
538
539             Hint: Use the compile autotest to see whether a C++ feature is supported
540             by all compilers in the test farm.
541
542         \o  All code is ASCII only (7-bit characters only, run \c {man ascii} if unsure)
543             \list
544                 \o  Rationale: We have too many locales inhouse and an unhealthy
545                     mix of UTF-8 and Latin1 systems. Usually, characters > 127 can
546                     be broken without you even knowing by clicking Save in your
547                     favourite editor.
548                 \o  For strings: Use \\nnn (where nnn is the octal representation
549                     of whatever locale you want your string in) or \xnn (where nn
550                     is hexadecimal).
551                     For example: QString s = QString::fromUtf8("\\213\\005");
552               \o  For umlauts in documentation, or other non-ASCII characters,
553                   either use the qdoc \c {\unicode} command or use the relevant macro.
554                   For example: \c{\uuml} for \uuml.
555            \endlist
556         \o  Use static keywords instead of anonymous namespaces whenever possible.
557             A name localized to the compilation unit with static is
558             guaranteed to have internal linkage. For names declared in anonymous
559             namespaces, the C++ standard unfortunately mandates external linkage
560             (ISO/IEC 14882, 7.1.1/6, or see various discussions about this on the gcc mailing
561             lists).
562     \endlist
563
564     \section3 Null Pointers
565
566     Using a plain zero (0) for null pointer constants is always correct and
567     least effort to type.
568
569     \code
570     void *p = 0;
571
572     -NOT-
573
574     void *p = NULL;
575
576     -NOT-
577
578     void *p = '\0';
579
580     -NOT-
581
582     void *p = 42 - 7 * 6;
583     \endcode
584
585     \note As an exception, imported third party code as well as code
586     interfacing the native APIs (src/support/os_*) can use NULL.
587
588     \section2 Using QObject
589
590     \list
591         \o  Every QObject subclass must have a Q_OBJECT macro, even if it
592             does not have signals or slots, if it is intended to be used
593             with qobject_cast<>. See also \l{Casting}.
594         \o  Normalize the arguments for signals and slots
595             (see \l{http://doc.qt.nokia.com/4.7/qmetaobject.html#normalizedSignature}{QMetaObject::normalizedSignature}
596             inside connect statements
597             to safely make signal and slot lookup a few cycles faster.
598             You can use $QTDIR/util/normalize to normalize existing code.
599     \endlist
600
601     \section2 File Headers
602
603     If you create a new file, the top of the file should include a
604     header comment equal to the one found in other source files of Qt Creator.
605
606     \section2 Including Headers
607
608     \list
609         \o  Use the following format to include Qt headers:
610             \c{#include <QtCore/QWhatEver>}.
611         \o  Arrange includes in an order that goes from specific to generic to
612             ensure that the headers are self-contained. For example:
613         \list
614             \o  \c{#include "myclass.h"}
615             \o  \c{#include "otherclassinplugin.h"}
616             \o  \c{#include <otherplugin/someclass.h>}
617             \o  \c{#include <QtModule/QtClass>}
618             \o  \c{#include <stdthing>}
619             \o  \c{#include <system.h>}
620         \endlist
621         \o  Enclose headers from other plugins in square brackets (<>) rather than
622             quotation marks ("") to make it easier to spot external dependencies in
623             the sources.
624         \o  Add empty lines between long blocks of \e peer headers and try to
625             arrange the headers in alphabetic order within a block.
626     \endlist
627
628     \section2 Casting
629
630     \list
631         \o  Avoid C casts, prefer C++ casts (\c static_cast, \c const_cast,
632             \c reinterpret_cast) Both \c reinterpret_cast and
633             C-style casts are dangerous, but at least \c reinterpret_cast
634             will not remove the const modifier.
635         \o  Do not use \c dynamic_cast, use \c {qobject_cast} for QObjects, or
636             refactor your design, for example by introducing a \c {type()}
637             method (see QListWidgetItem), unless you know what you do.
638     \endlist
639
640     \section2 Compiler and Platform-specific Issues
641
642     \list
643         \o  Be extremely careful when using the question mark operator.
644             If the returned types are not identical, some compilers generate
645             code that crashes at runtime (you will not even get a compiler warning):
646             \code
647             QString s;
648             // crash at runtime - QString vs. const char *
649             return condition ? s : "nothing";
650             \endcode
651
652         \o  Be extremely careful about alignment.
653
654             Whenever a pointer is cast such that the required alignment of
655             the target is increased, the resulting code might crash at runtime
656             on some architectures. For example, if a \c {const char *} is cast to a
657             \c {const int *}, it will crash on machines where integers have to be
658             aligned at two-byte or four-byte boundaries.
659
660             Use a union to force the compiler to align variables correctly.
661             In the example below, you can be sure that all instances of
662             AlignHelper are aligned at integer-boundaries:
663             \code
664             union AlignHelper
665             {
666                 char c;
667                 int i;
668             };
669             \endcode
670
671         \o  Anything that has a constructor or needs to run code to be
672             initialized cannot be used as global object in library code,
673             since it is undefined when that constructor or code will be run
674             (on first usage, on library load, before \c {main()} or not at all).
675
676             Even if the execution time of the initializer is defined for
677             shared libraries, you will get into trouble when moving that code
678             in a plugin or if the library is compiled statically:
679
680             \code
681             // global scope
682
683             -NOT-
684
685             // Default constructor needs to be run to initialize x:
686             static const QString x;
687
688             -NOT-
689
690             // Constructor that takes a const char * has to be run:
691             static const QString y = "Hello";
692
693             -NOT-
694
695             QString z;
696
697             -NOT-
698
699             // Call time of foo() undefined, might not be called at all:
700             static const int i = foo();
701             \endcode
702
703             Things you can do:
704
705             \code
706             // global scope
707             // No constructor must be run, x set at compile time:
708             static const char x[] = "someText";
709
710             // y will be set at compile time:
711             static int y = 7;
712
713             // Will be initialized statically, no code being run.
714             static MyStruct s = {1, 2, 3};
715
716             // Pointers to objects are OK, no code needed to be run to
717             // initialize ptr:
718             static QString *ptr = 0;
719
720             // Use Q_GLOBAL_STATIC to create static global objects instead:
721
722             Q_STATIC_GLOBAL(QString, s)
723
724             void foo()
725             {
726                 s()->append("moo");
727             }
728             \endcode
729
730             \note Static objects in function scope are no problem. The constructor
731             will be run the first time the function is entered. The code is not
732             reentrant, though.
733
734         \o  A \c char is signed or unsigned dependent on the architecture. Use signed
735             \c char or \c uchar if you explicitely want a signed or unsigned char.
736             The following code will break on PowerPC, for example:
737
738             \code
739             // Condition is always true on platforms where the
740             // default is unsigned:
741             if (c >= 0) {
742                 ...
743             }
744             \endcode
745
746         \o  Avoid 64-bit enum values. The AAPCS (Procedure Call Standard
747             for the ARM Architecture) embedded ABI hard codes
748             all enum values to a 32-bit integer.
749
750         \o  Do not mix const and non-const iterators. This will silently crash
751             on broken compilers.
752             \code
753             for (Container::const_iterator it = c.constBegin(); it != c.constEnd(); ++it)
754
755             -NOT-
756
757             for (Container::const_iterator it = c.begin(); it != c.end(); ++it)
758             \endcode
759     \endlist
760
761     \section2 Esthetics
762
763     \list
764         \o Prefer enums to define const over static const int or defines.
765            Enumeration values will be replaced by the compiler at compile time,
766            resulting in faster code. Defines are not namespace safe.
767         \o Prefer verbose argument names in headers.
768            Qt Creator will show the argument names in their completion box.
769            It will look better in the documentation.
770     \endlist
771
772     \section2 Inheriting from Template or Tool Classes
773
774     Inheriting from template or tool classes has the following potential
775     pitfalls:
776
777     \list
778         \o  The destructors are not virtual, which can lead to memory leaks.
779         \o  The symbols are not exported (and mostly inline), which can lead to
780             symbol clashes.
781     \endlist
782
783     For example, library A has class \c {Q_EXPORT X: public QList<QVariant> {};}
784     and library B has class \c {Q_EXPORT Y: public QList<QVariant> {};}.
785     Suddenly, QList symbols are exported from two libraries which results in a
786     clash.
787
788     \section2 Namespacing
789
790     Read \l {http://developer.qt.nokia.com/wiki/Qt_In_Namespace}{Qt In Namespace}
791     and keep in mind that all of Qt Creator is \e{namespace aware} code.
792
793     \section2 Conventions for Public Header Files
794
795     Our public header files have to survive the strict settings of
796     some of our users. All installed headers have to follow these rules:
797
798     \list
799
800         \o  No C style casts (\c{-Wold-style-cast}). Use \c static_cast, \c const_cast
801             or \c reinterpret_cast, for basic types, use the constructor form:
802             \c {int(a)} instead of \c {(int)a}. For more information, see \l{Casting}.
803
804         \o  No float comparisons (\c{-Wfloat-equal}). Use \c qFuzzyCompare to compare
805             values with a delta. Use \c qIsNull to check whether a float is
806             binary 0, instead of comparing it to 0.0, or, prefered, move
807             such code into an implementation file.
808
809        \o  Do not hide virtual methods in subclasses (\{-Woverloaded-virtual}).
810            If the baseclass A has a virtual \c {int val()} and subclass B an
811            overload with the same name, \c {int val(int x)}, the A \c val function
812            is hidden. Use the \c using keyword to make it visible again, and
813            add the following silly workaround for broken compilers:
814            \code
815                class B: public A
816                {
817                #ifdef Q_NO_USING_KEYWORD
818                inline int val() { return A::val(); }
819                #else
820                using A::val;
821                #endif
822                };
823            \endcode
824
825         \o  Do not shadow variables (\c{-Wshadow}).
826
827         \o  Avoid things like \c {this->x = x;} if possible.
828
829         \o  Do not give variables the same name as functions declared in
830             your class.
831
832         \o  To improve code readability, always check whether a preprocessor
833             variable is defined before probing its value (\c{-Wundef}).
834
835             \code
836               #if defined(Foo) && Foo == 0
837
838               -NOT-
839
840               #if Foo == 0
841
842               -NOT-
843
844               #if Foo - 0 == 0
845            \endcode
846
847     \endlist
848
849     \section1 Documentation
850
851     The documentation is generated from source and header files. You document
852     for the other developers, not for yourself. In the header files, document
853     interfaces. That is, what the function does, not the implementation.
854
855     In the .cpp files, you can document the implementation if the
856     implementation is not obvious.
857
858 */