Directives (Programming)

By: Dusty Arlia
Published on Sunday, August 11, 2013, 10:55 AM
Last Updated on Tuesday, July 07, 2015 at 9:42 PM
Total Updates: 2

A directive or pragma (from "pragmatic") is a programming language construct that specifies how a compiler (or assembler or interpreter) should process its input. Directives can specify global behavior or only affect a block of code. Normally directives must be followed, but in C pragmas, directives are optional compiler hints and may be ignored. Directives don't perform any actions themselves; only change the behavior of the compiler.

The term directives could also be used to refer to proprietary third party tags and commands (or markup) embedded in code that extends the existing compiler, assembler, and language constructs present in the development environment. The term directive is also used in a number of ways like the term command.

Directives date back to the programming language ALGOL 68 where they are known as pragmats (from "pragmatic"). In newer languages like C, this has been abbreviated to "pragma". ECMAScript uses the keyword use for directives.