includes.txt 1.73 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
includes.txt
============

The include policy for the files in app/ is as follows:

Each subdirectory has a <module>-types.h file which defines the type
space known to this module. All .c files in the directory include this
(and only this) <module>-types.h file.  <foo>-types.h files from other
modules are included from the <module>-types.h file only. This way
<module>-types.h becomes the only place where the namespace known to a
module is defined.


***** .h files *****

No .h file includes anything, with two exceptions:

- objects include their immediate parent class
- if the header uses stuff like time_t (or off_t), it includes
  <time.h> (or <sys/types.h>). This only applies to system stuff!


***** .c files *****

The include order of all .c files of a module is as follows:

Sven Neumann's avatar
Sven Neumann committed
27
/* example of a .c file from app/core */
28

29
#include "config.h"             /* always and first                          */
30 31 32 33 34 35 36 37 38

#include <glib.h>               /* *only* needed if the file needs stuff     */
                                /* like G_OS_WIN32 for conditional inclusion */
                                /* of system headers                         */

#include <system headers>       /* like <stdio.h>                            */

#include <glib-object.h>

Sven Neumann's avatar
Sven Neumann committed
39
#include "libgimpfoo/gimpfoo.h" /* as needed, e.g. "libgimpbase/gimpbase.h"  */
40 41
#include "libgimpbar/gimpbar.h"

Sven Neumann's avatar
Sven Neumann committed
42
#include "core-types.h"         /* and _no_ other foo-types.h file           */
43 44 45 46 47 48 49 50

#include "base/foo.h"           /* files from modules below this one         */
#include "base/bar.h"

#include "gimp.h"               /* files from this module                    */
#include "gimpimage.h"
#include "gimpwhatever.h"

51
#include "gimp-intl.h"          /* if needed, *must* be the last include     */