Professional Documents
Culture Documents
/* */
(b) The first word in the function name is the name of the primary
input data structure (if there is one).
(c) Variable names are as short as possible, without causing confusion.
(d) Pointers to data structures are typically named by the type of
struct, without a leading 'p'; e.g., pixt, boxt.
(e) When ptrs are input to a function, in order to return a value,
if the local name would be 'ave', the pointer is 'pave'.
(f) Preprocessor variables and enums are named all caps,
with '_' between parts.
(g) There are very few globals in the library. Of these, there
are just a handful of static globals that can be changed.
Globals are named with each word beginning with a capital; e.g.,
ImageFileFormatExtensions[]
Static globals are named like preprocessor variables, except
they are prepended by 'var_'; e.g.,
var_PNG_WRITE_ALPHA
Functions that set globals are named with a pre-pended 'l_'; e.g.,
l_pngSetWriteAlpha()
(4) Arg checking
Both number values and ptrs can be returned in function arguments.
The following applies equally to both types, and happens at the
beginning of the function. We distinguish between returned entities
that are optional and required.
(a) First, all optional values are initialized if possible:
if (ppixd) *ppixd = NULL; // Pix **ppixd is optional
(b) Second, if there is more than 1 required value, each is
initialized if possible:
if (pnar) *pnar = NULL; // Numa **pnar is required
if (pnag) *pnag = NULL; // Numa **pnag is required
Then all required arguments are tested in arbitrary order.
But if there is exactly 1 required value, it is checked and
initialized if possible:
if (!ppixd)
return ERROR_INT("&pixd not defined, procName, 1);
*ppixd = NULL;
(5) Miscellaneous
(a) Look around at the code after reviewing the guidelines.
(b) Return nothing on stdout.
(c) Returns to stderr should be blockable by compiler flags, such
as NO_CONSOLE_IO, and by setting message severity thresholds
both at compile and at run time. Naked fprintf(stderr, ...)