C++
===

Modules
.......

Modules can be added, renamed and removed by just creating, renaming
or removing files in the `src' directory.  No further change to the
`Howto.cook' is needed.  Modules consist of:  

* Simple modules that consist of only a header file 

* Program modules:

	CHESS_EVALUATOR is an example of a "program module".  Program
        modules are compiled into programs by passing their name
        (e.g. `chess_evaluator') to `sh/build'.  Program modules don't
        have a header file (`src/*.hh').  

* Other modules:

	Other modules consist of a `.cc' and of a `.hh' file.  


Macros
......

The macro `NDEBUG' is defined by the cookfile when compiling release
versions.  When `NDEBUG' is not defined, modules enable debugging
behavior.  Modules do internal checks when NDEBUG is not defined.  The
behavior of modules is the same whether NDEBUG is defined or not, but
things will run slower when it is not defined.   

Macros that are used or defined by a module are prepended by the name
of the module.  The macro `FLOPPY_CHECK' would be used by the FLOPPY
module.  

Modules use the macro `<module>_INCLUDED' to prevent multiple
definitions in header files. 

Other macros can be defined by adding their definition to $CXXFLAGS,
using the `-D' option.


Preprocessor
............

Deprecated source files are marked with

	   #error unused



C Libraries
...........

Modules that use C library functions must include the right header
files for the library and provide a script in the `ld' directory if
special linking flags are needed for that library.  If multiple
modules use one library, it is recommended to create one module whose
sole purpose is to a) include the right header files and b) provide
the script in `ld'.  Thus linking flags are not used twice.  


GNU Extensions
..............

GNU extensions to the C++ language are used.  The programs cannot be
compiled with another compiler than Gcc. 


Templates
.........

Template functions are defined in header files. 


Integer Types
.............

The INT module defines the integer types from C99.  `unsigned',
`signed', `long', `short' and `long long' are used only when a library
requires it.  


Exceptions
..........

Exceptions are not used.  Functions that may fail return `bool'. 


C++ libraries
.............

C++ libraries are not used.  

<typeinfo> is used in debug mode. 

RTTI is disabled in release mode. 


Coding Style
............

See the source.  `etc/emacs' is a sample Emacs configuration file.  


Class Definitions
.................

Declaration are ordered by:

    1) Access:  public, protected, private.
    2) Declaration type:  types, members, constructors, destructor,
                          functions.  

Inline member function are defined in the class body.  They must
precede all their calls from other inline member functions of the same
class.  Otherwise they wouldn't be inlined.  


Quoting
.......

To quote C variable names in english, use ALL CAPS and no leading
underscore.  C functions are not quoted. 

int Get_Value(int index);

is documented as function Get_Value() with parameter INDEX.  


Variable and macro names
........................

Words in variable names are separated by an underscore (`_'). 

Function names have each word capitalized:    

    int Get_Value(); 

Functional macros have names of functions: 

    #define Get_Value() (0)

Variable names are lower-case:

    int count= 0;

Class function parameters that represent new values for a class member
should have the class member's name with "new" prepended:

    void Set_Size(int new_size)
    {
	    size= new_size; 
    }


Virtual functions
.................

The name of virtual function should begin with the initials of the
class in which they are declared. 

Warning:  In derived classes that implement virtual functions, a typo
in the name of the function will be an error that the compiler cannot,
because we can't tell it one of the base classes has this function as
virtual.  
