next up previous contents index
Next: Example: A LAL primer Up: Header LALStatusMacros.h Previous: Using the compilation flags   Contents   Index

Notes

Why are the status handling routines written as macros rather than functions? There are three good reasons.

First, many of the handling routines must be able to force an exit from the function calling them. This cannot be done if the routine is in its own function, except by raising signal flags (which is a Bad Thing according to LAL standards).

Second, it is useful for these routines to assign a status structure's file and line fields using the __FILE__ and __LINE__ macros. If the routine is its own function, then these will just give the file and line number where the error handling routine is defined. If the routine is a macro, then these will give the file and line number where the macro was called, which is much more interesting.

Third, by expanding macros at compile time, the runtime performance of the resulting code is marginally better. Most of these macros will, under nominal conditions, reduce to a single conditional test of an integer value, with no additional overhead from function calling and parameter passing. Thus programmers can be encouraged to include extensive error trapping in all their routines, without having to worry about compromising performance.

It should be mentioned that, for these reasons, compiling a module with the NOLALMACROS flag above does not actually eliminate the status handling macros. Rather, the macros are modified to call specialized functions that do most (but not all) of the processing.


next up previous contents index
Next: Example: A LAL primer Up: Header LALStatusMacros.h Previous: Using the compilation flags   Contents   Index
LAL test account 2003-10-23