Directive (programming): Difference between revisions

Content deleted Content added
Reworked introduction
Line 1:
In [[computer programming]], the wordterm '''directive''' mayis referapplied toin anya variety of severalways relatedthat concepts.are Generally,similar programmingto languagesthe distinguish between [[source code]]term ''instructionscommand'', whichit areis translatedalso intoused outputto suchdescribe assome [[machineprogramming codelanguage]] orconstructs data; and ''directives''(eg., whichthose dospecifying nothow correspond to any particular part of the output, but simply tell thea [[compiler]] or [[assembler]] ''how''should toprocess treat theits input).
 
==Assembly language==
In [[assembly language]], directives generally tellspecify thesuch assemblerinformation as the target platform, mark the separations between [[section]]s, and so on. TheFor instance, the commonly seen mnemonicdirective "ALIGN", which inserts in the current section as many [[byte]]s as needed to preserve word-alignment, is also generally referred to as a "directive", despite the fact that it does correspond to a particular construct in the generated code.
 
==The C preprocessor==
{{main|C preprocessor}}
 
In [[C (programming language)|C]] and [[C++]], the language providessupports a simple [[macro preprocessor]] that essentially makes a pass over the [[source code]] before the traditional [[lexing]] and [[parsing]] of the compiler proper. (See [[C preprocessor]].) Source lines that areshould be intendedhandled forby the preprocessor, such as <code>#define</code> and <code>#include</code>, are referred to as ''[[preprocessor directive]]s''.
 
<!-- The following is not Standard C, it is an extension supported by one implementation.
One notable C preprocessor directive is <code>[[pragma once|#pragma once]]</code>, which instructs the compiler to include the current source file only once, making it effectively [[idempotent]], and providing an alternative in C and C++ to [[include guard|#include guards]].
-->
 
Syntactic constructs similar to C's preprocessor directives, such as [[C Sharp|C#]]'s <code>#region</code>, are also typically called "directives", although in these cases there may not be any real preprocessing phase involved.