[prev] [index] [next]

Variations (cont)

Variations are typically embedded in source code via the C pre-processor (cpp):

The cpp directive #ifdef can cause code to be included/ignored.

Example:

#ifdef BSD              |  fgets(strbuf,100,stdin);
#include <strings.h>    |  #ifdef BSD == 4
#else                   |  cp = index(strbuf, ':');
#include <string.h>     |  #else
#endif                  |  cp = strchr(strbuf, ':');
...                     |  #endif
char *cp, strbuf[100];  |