SPL Macro Preprocessor


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,



becomes: (9*9)


Because the preprocessor performs literal text substitution, parentheses are very important in parametized macros. The expression:




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:





define a macro


define a function


include a file


else if macro test


Else clause of an #if or #elif


Process if macro defined


Process if macro not defined


include a file


delete a macro