SPL includes C/C++ like preprocessor directives to include files and perform macro substitutions. For example,
#include "dsp.h"
#define EPSVAL 1.0e-14
instructs SPL to include dsp.h in the current SPL file and defines the constant EPSVAL. The preprocessor substitutes 1.0e-14 whenever it finds the expression EPSVAL.
Unlike C/C++, SPL macros are global and are in effect during the entire session. Macros can also accept arguments. For example:
#define SQR(S) (S*S)
The body of the macro is substituted whenever the name of the macro is used. Thus,
SQR(9)
becomes: (9*9)
Because the preprocessor performs literal text substitution, parentheses are very important in parametized macros. The expression:
SQR(9+1)
becomes: (9+1*9+1) == 9+9+1 == 19
The SQR macro is properly defined as:
#define SQR(S) ((S)*(S))
and SQR(9+1)
becomes: ((9+1)*(9+1)) == ((10)*(10)) == 100
The include directives using the angled brackets, <>, search for include files in the standard SPL path. For example:
#include <series.h>
The following preprocessor directives are supported:
Directive |
Description |
#define |
define a macro |
#deffun |
define a function |
#include |
include a file |
#elif |
else if macro test |
#else |
Else clause of an #if or #elif |
#ifdef |
Process if macro defined |
#ifndef |
Process if macro not defined |
#include |
include a file |
#undef |
delete a macro |