Content deleted Content added
m Robot-assisted disambiguation (you can help!): C programming language |
Quuxplusone (talk | contribs) Merged from Compiler directive |
||
Line 1:
In [[computer programming]], the word '''directive''' may refer to any of several related concepts. Generally, programming languages distinguish between [[source code]] ''instructions'', which are translated into output such as [[machine code]] or data; and ''directives'', which do not correspond to any particular part of the output, but simply tell the [[compiler]] or [[assembler]] ''how'' to treat the input.
==Assembly language==
In [[assembly language]], directives generally tell the assembler the target platform, mark the separations between [[section]]s, and so on. The mnemonic "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}}
{{main|Preprocessor directive}}
In [[C (programming language)|C]] and [[C++]], the language provides 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 are intended for the preprocessor, such as <code>#define</code> and <code>#include</code>, are referred to as ''[[preprocessor directive]]s''.
===C/C++===▼
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.
*[[Include guard]]
==In other high-level languages==
In [[Ada (programming language)|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 [[comment (computer programming)|comment]]s. 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 <code>#include "file"</code> directive is the significant comment <code>{$I "file"}</code>.
In [[Perl]], the construct <code>use strict;</code> is referred to as a "directive".{{fact}}
[[de:Compiler-Anweisung]]
[[es:Pragma]]
[[zh:編譯器指導指令]]
[[Category:Computer programming]]
|