[ Directives | Reference Manual | Alphabetic Index ]

# pragma(+Option)

Enable or disable compilation or other source processing options.

Option
  An atom.

## Description

The pragma/1 directive allows to control various compiler options, or other source processing options. A pragma can only be used as a directive in source files or lists given to compile_term/1,2. The effect of a pragma is local to a source file (unlike set_flag/2). Settings are in effect until the next pragma that overrides it or until the end of the file.

        Option     Effect
       ---------------------------------------------------------------
        [no]debug        generate debuggable code
        [no]expand       do goal expansion/inline compilation
        opt_level(N)     set optimizer level (N>=0)
        [no]skip         set the skipped flag for all compiled predicates
        system           set the type of all compiled predicates to 'built_in'
        [no]warnings     generate compiler warnings

The default for debug/nodebug depends on the global flag debug_compile and the debug compiler option. The default for expand/noexpand depends on the global flag goal_expansion and the expand_goals compiler option. The default for opt_level depends on the opt_level compiler option. The default for skip is off. The default for warnings is on. The global flags are set with set_flag/2 and tested with get_flag/2.

Pragmas which the compiler does not recognise are silently ignored by the compiler, but are recorded and can be retrieved using current_pragma/1. Such pragmas can be atoms or structures with arbitrary arguments.

### Modes and Determinism

- pragma(+) is det

### Exceptions

(148) bad pragma
  An unknown Option was given.

## Examples

    :- pragma(debug).
    :- pragma(expand).
    twice(X, Y) :-      % this is compiled into debuggable
        Y is 2*X.       % code with expanded arithmetic

## See Also

compile / 1, env / 0, get_flag / 2, get_flag / 3, pred / 1, set_flag / 3, set_flag / 2, skipped / 1, unskipped / 1, current_pragma / 1