I search for solutions in this order: Past Code, Unreal Source, Wiki, BUF, groups.yahoo, google, screaming at monitor. – RegularX

Compiler directives

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

Compiler directives are lines in UnrealScript source files that affect compiler behavior and have no meaning at runtime. They are not really used anymore in Unreal Engine 3, which comes with a powerful preprocessor instead.

Directives are parsed during the compile process, not before that. This means they cannot be used in defaultproperties or cpptext sections. In fact, any directives in cpptext blocks will end up in exported header files for preprocessing by the C++ compiler.

Syntax

Compiler directives must be placed on a separate line. The syntax is as follows:

#directivename parameters

There must not be anything else before the # on that line and there shouldn't be anything after the directive name and parameters, except maybe a line comment. Directive names are case-insensitive, like any other part of UnrealScript syntax.

Unreal Engine 1/2

call

Similar to the "exec" console command in the editor and the game. Loads a list of console commands from a text file and executes them.

See exec commands for a useful selection of commands.

error

Immediately stops compiling with the message: "#Error directive encountered"

Note that there is no built-in conditional compiling, so using this directive may be quite pointless without an external preprocessor tool like UCPP.

exec

The most-used directive and probably the only one most UnrealScript programmers ever need to use. The #exec directive executes an editor console command in the context of the compiler.

See exec commands for a useful selection of commands.

Unreal Engine 2

include

Loads a text file and replaces the #include line with its content.

There are several things to watch out for when using this directive:

  • Line numbers reported in errors and warnings after the #include line will reflect the source text with the included content, so they no longer match the original source line numbers.
  • If the included file contains a defaultproperties block, it is not included directly. Instead, its content is inserted into the class's defaultproperties block.

Unreal Engine 3

The only known directive in Unreal Engine 3 is #linenumber, which is inserted by the preprocessor after an `include macro to make sure the compiler reports the line numbers the user expects.