compiler directive

Also found in: Dictionary, Medical, Legal, Financial.

compiler directive

A statement written in the source code of a program that lets the programmer instruct the compiler to perform a specific operation within the compilation phase. For example, the #include directive incorporates the contents of a header file to the compilation, which can add a little or a lot of code. The #define directive is used to define a constant, for example #define LINEFEED '\x0A' lets the programmer use a more friendly LINEFEED mnemonic instead of the hexadecimal \x0A notation. The #define can also be used for a condition. For example, the statement #define DEBUG allows the programmer to execute code following #if (DEBUG) to display results used only while testing.

A compiler directive is often required when the same source code is compiled on two different hardware platforms. For example, the code might be compiled and tested on Windows but compiled and run on Linux. In such cases, a few commands in the code may be different, and the #define and #if directives accomplish this.

Preprocessor Directive
In some languages, such as C/C++, compiler directives as in the above examples are called preprocessor directives because they are handled before the actual compilation process.

Pragmas are directives that are predefined and specific to the compiler or a group of compilers. For example, #pragma inline means that assembly code is included within the source code. See compiler.
Copyright © 1981-2019 by The Computer Language Company Inc. All Rights reserved. THIS DEFINITION IS FOR PERSONAL USE ONLY. All other reproduction is strictly prohibited without permission from the publisher.
References in periodicals archive ?
It is notable that the compiler directives can be automatically inserted through compile techniques.
Originally formed as an application programming interface (API) in 1997, OpenMP is a platform-independent set of compiler directives that supports Fortran, C, and C++.
In particular, Microsoft had added unauthorized keywords and compiler directives, had modified the compiler to support these unauthorized extensions and had failed to implement the Java Native Interface (JNI).
Now, its support of OpenMP will also allow code developers to use a standard set of compiler directives providing easy portability to other vendor systems.