Compiler directive

From Wikipedia, the free encyclopedia

In computer science, a compiler directive is data embedded in source code by programmers to tell compilers some intention about compilation. A compiler directive often tells the compiler how to compile; other source code tells the compiler what to compile.

[edit] Examples

  • A compiler directive could tell the compiler whether to do range checking on array indexes or trust that the programmer has not written code that can cause an error.
  • An #include preprocessor directive in C tells the compiler to insert another text file at the current point.
  • The #pragma once construct in some implementations of C serves a purpose similar to that of #include guards.
  • In .net the #pragma region lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor.

In Ada, compiler directives are called pragmas (short for "pragmatic information"). In other languages, such as Turbo Pascal, they are called significant comments.

For example strict - Perl pragma to restrict unsafe constructs

In other languages