next up previous contents index
Next: 6.2.2 getparam.h Up: 6.2 The NEMO Macro Previous: 6.2 The NEMO Macro   Contents   Index

6.2.1 stdinc.h

The macro package stdinc.h provides all basic definitions that ALL of NEMO's code must include as the first include file. It also replaces the often used stdio.h include file in C programs. The stdinc.h include file will provide us with a way to standardize on future expansions, and make code more machine/implementation independent (e.g. POSIX.1). In addition, it defines a more logical standard for C notation. For example, the normal C practice of using pointers to character for pointer to byte, or integer for bool, tends to encourage a degree of sloppy programming, which can be hard to understand at a later date.

A few of the basic definitions in this package:

$\bullet$ NULL:
macro for 0, used to distinguish null characters and null pointers. This is often already defined by stdio.h. There is potential trouble when NULL has been set to (void *)0, '\0' is OK though. Example on IBM's AIX operating system.

$\bullet$ bool:
typedef for short int or char, used to specify boolean data. See also next item. 6.2.

$\bullet$ TRUE, FALSE:
macros for 1 and 0, respectively, following normal C conventions.

$\bullet$ byte:
typedef for unsigned char, used to specify byte-sized data.

$\bullet$ string:
typedef for char *, used to point to strings. Don't use string for pointers you increment, decrement or explicitly follow (using *); such pointers are really char *.

$\bullet$ real, realptr:
typedef for float or double (float * or double *, respectively), depending on the use of the SINGLEPREC flag. The default is double.

$\bullet$ proc, iproc, rproc:
typedefs for pointers to procedures (void functions), integer-valued functions and real-valued functions respectively.

$\bullet$ local, permanent:
macros for static. Use local when declaring variables or functions within a file to be local to that file. They will not appear in the symbol table be usable as external symbols. Use permanent within a function, to retain their value upon subsequent re-entries in that function.

macros for $\pi$, $2\pi$, $4\pi$, $\pi/2$ and $4\pi/3$, respectively.

$\bullet$ ABS(x), SGN(x):
macros for absolute value and sign of x, irrespective of the type of x.. Beware of side effects.

$\bullet$ MAX(x,y), MIN(x,y):
macros for the maximum and minimum of x,y, irrespective of the type of x,y. Beware of side effects.

$\bullet$ stream:
typedef for FILE *. They are mostly used with the NEMO functions stropen and strclose, which are functionally similar to fopen(3) and fclose(3), plus some added NEMO quirks. (see section [*] below)

next up previous contents index
Next: 6.2.2 getparam.h Up: 6.2 The NEMO Macro Previous: 6.2 The NEMO Macro   Contents   Index
(c) Peter Teuben