Directive (programming)

Directive (programming)

In computer programming, the term directive is applied in a variety of ways that are similar to the term command. It is also used to describe some programming language constructs (e.g. those specifying how a compiler or assembler should process its input).

To distinguish a directive from a command or statement, a directive may involve a pre or post processing command or macro. Its second use involves a statement that affects local or more global options or that applies to a block of programming code but by itself does not perform any action.

This term could be used to refer to proprietary third party tags and commands (or markup) embedded in code or comments that result in additional executable processing that extend the existent compiler, assembler and language constructs present in the development environment.


Assembly language

In assembly language, directives generally specify such information as the target platform, mark the separations between sections, and so on. For instance, the commonly seen directive "ALIGN", which inserts in the current section as many bytes as needed to preserve word-alignment, is generally referred to as a "directive", despite the fact that it does correspond to a particular construct in the generated code.

The C preprocessor

In C and C++, the language supports a simple macro preprocessor. Source lines that should be handled by the preprocessor, such as #define and #include are referred to as preprocessor directives.

Another C construct, the #pragma directive, is used to instruct the compiler to use pragmatic or implementation-dependent features. Two most notable users of this directive are OpenMP and OpenHMPP

Syntactic constructs similar to C's preprocessor directives, such as C#'s #if, are also typically called "directives", although in these cases there may not be any real preprocessing phase involved.

In other high-level languages

In Ada, compiler directives are called pragmas (short for "pragmatic information").

In Turbo Pascal, directives are called significant comments, because in the language grammar they follow the same syntax as comments. In Turbo Pascal, a significant comment is a comment whose first character is a dollar sign and whose second character is a letter; for example, the equivalent of C's #include "file" directive is the significant comment {$I "file"}.

In Perl, the keyword "use" can introduce a "pragma", such as use strict; or use utf8;. ECMAScript also uses this keyword to introduce "pragmas".

In Visual Basic, the statement "Option Explicit On" instructs the VB compiler to require all variable declarations before use. There are also a few other variations to the Option keyword, such as:

  • Option Strict On - Requires that implicit type casts are only to wider types.
  • Option Compare Binary - Tells the compiler to compare text using a binary algorithm.
  • Option Compare Text - Tells the compiler to compare text using a textual algorithm.


Wikimedia Foundation. 2010.

Look at other dictionaries:

  • Directive — may refer to: Directive (European Union), a legislative act of the European Union Directive (poem), a highly acclaimed poem by Robert Frost Directives, used by United States Government agencies (particularly the United States Department of… …   Wikipedia

  • Comparison of programming languages (syntax) — Programming language comparisons General comparison Basic syntax Basic instructions Arrays Associative arrays String operations …   Wikipedia

  • Hybrid Multicore Parallel Programming — HMPP (Hybrid Multicore Parallel Programming) est un ensemble d outils de développement au service de la programmation multi cœurs hybride. HMPP est un produit commercial de CAPS entreprise [1]. Sommaire 1 Description 2 Les principes 3 …   Wikipédia en Français

  • Oxygene (programming language) — Oxygene Developer RemObjects Software Stable release 3.0.21 (August 29, 2009; 2 years ago (2009 08 29)) Influenced by Object Pas …   Wikipedia

  • Ada (programming language) — For other uses of Ada or ADA, see Ada (disambiguation). Ada Paradigm(s) Multi paradigm Appeared in 1980 Designed by MIL STD 1815/Ada 83: Jean Ichbiah Ada 95: Tucker Taft Ada 2005: Tucker Taft Stable release …   Wikipedia

  • C (programming language) — C The C Programming Language[1] (aka K R ) is the seminal book on C …   Wikipedia

  • Racket (programming language) — Racket Paradigm(s) Multi paradigm: Functional, Procedural, Modular, Object oriented, Reflective, Meta Appeared in 1994 Developer …   Wikipedia

  • TUTOR (programming language) — Infobox programming language name = TUTOR (aka PLATO Author Language) paradigm = imperative (procedural) year = c. 1965 designer = Paul Tenczar Richard Blomme [from page 4 of The TUTOR Language by Bruce Sherwood, 1974.] developer = Paul Tenczar… …   Wikipedia

  • Main function (programming) — In some programming languages, the main function is where a program starts execution. It is generally the first user written function run when a program starts (some system specific software generally runs before the main function), though some… …   Wikipedia

  • Null (computer programming) — Null has several meanings in computer programming.;Null pointer or null reference * Null is a special pointer value (or other kind of object reference) used to signify that a pointer intentionally does not point to (or refer to) an object. Such a …   Wikipedia