Main article: 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.
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.
All preprocessor commands begin with a hash symbol (#) with the exception of the keywords export, import and module in C++ (handled by the preprocessor prior to C++26).1
Directives date to JOVIAL.2
COBOL has a COPY directive.
In ALGOL 68, directives are known as pragmats (from "pragmatic"), and denoted pragmat or pr; in newer languages, notably C, this has been abbreviated to "pragma" (no 't').
A common use of pragmats in ALGOL 68 is in specifying a stropping regime, meaning "how keywords are indicated". Various such directives follow, specifying the POINT, UPPER, RES (reserved), or quote regimes. Note the use of stropping for the pragmat keyword itself (abbreviated pr), either in the POINT or quote regimes:
Today directives are best known in the C language, of early 1970s vintage, and continued through the current C99 standard, where they are either instructions to the C preprocessor, or, in the form of #pragma, directives to the compiler itself. They are also used to some degree in more modern languages; see below.
"P1857R1 - Modules Dependency Discovery". https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1857r1.html ↩
"Chapter 17 - Directives" (PDF). Computer Programming Manual for JOVIAL (J73) Language (PDF) (Technical report). June 1981. pp. 243–263. RADC-TR-81-143. Retrieved May 28, 2023. https://apps.dtic.mil/sti/pdfs/ADA101061.pdf#page=248 ↩
Steele 1990, Chapter 9: Declarations, p. 215–237. - Steele, Guy L. (1990). Common Lisp the Language. Digital Press. pp. 215–237. ISBN 1-55558-041-6. ↩
"7.20. Pragmas". GHC 7.8.3 Documentation. Retrieved 18 July 2014. http://www.haskell.org/ghc/docs/7.8.3/html/users_guide/pragmas.html ↩
dotnet-bot. "Lexical structure - C# language specification". docs.microsoft.com. Retrieved 2019-11-01. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure ↩
BillWagner. "#pragma - C# Reference". docs.microsoft.com. Retrieved 2019-11-01. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-pragma ↩
"Pragma statements supported by SQLite". www.sqlite.org. https://www.sqlite.org/pragma.html ↩
"Layout of a Solidity Source File — Solidity 0.8.27 documentation". docs.soliditylang.org. Retrieved 2024-06-03. https://docs.soliditylang.org/en/latest/layout-of-source-files.html#pragmas ↩
Feuerstein, Steven; Pribyl, Bill (23 January 2014). Oracle PL/SQL Programming (6 ed.). O'Reilly Media, Inc. (published 2014). ISBN 9781449324414. Retrieved 2016-06-16. PL/SQL has a PRAGMA keyword with the following syntax: PRAGMA instruction_to_compiler; [...] PL/SQL offers several pragmas [...] 9781449324414 ↩