This library, when loaded with
makes it possible to use primitives for conditional compilation in Prolog source files. After loading the library, the predicate ifdef/1 becomes global.:- lib(ifdef).
The compiler will then recognise conditional compilation directives which have the form
The elseif and else parts can be omitted.:- ifdef Condition1. <compile if Condition1 is true> :- elseif Condition2. <compile if Condition2 is true> .. :- else. % or :- else(Goal), Goal is ignored <compile if none of the above conditions holds> :- endif. % or :- endif(Goal), Goal is ignored
Note that this mechanism is implemented using the predicate compile_term/1 and so all procedures that are conditionally compiled have no associated source file, and so
will fail. Note also that if several streams are opened to the file being compiled, the result of the compilation may not be correct.get_flag(Proc, source_file, File).