Language features
Code to be common shared code must (unfortunately!) be written in
C, rather than any objective C or C++, to ensure maximum portability.
This section does not apply to code written for specific platforms.
C code must compile under either a conforming ANSI C compiler OR an
original Kernighan & Ritchie C compiler. Therefore, the __STDC__ macro
must be used to select alternative code where necessary.. ( example
)
Code should compile without warnings under an ANSI C compiler such
as gcc with all warnings enabled.
- Parameters and Arguments
- The PARAMS(()) macro is used to give a format
parameter list in a declataion so that it will be suppressed if the
compiler is not standard C - see example .. The ARGS1 macro is for
the declaration of the implementation, taking first the type then
the argument name. For n arguments, macros ARGn exists taking 2n arguments
each.
- #endif
- Do put the ending condition in a comment. Don't put it as
code - it won't pass all compilers.
- #elif
- Don't use it. Basic cpp doesn't know it.
- #preprocessor statements
- DON'T indent any preprocessor statements.
They must (for some compilers) begin in column 1.
- const
- This keyword does not exist in K&R C, so use the macro CONST
which expands to "const" under standard C and nothing otherwise. --
See HTUtils.h
(part of: style guide ) _________________________________________________________________
Tim BL