Compiler directive

From Free net encyclopedia

Revision as of 20:05, 28 March 2006; view current revision
←Older revision | Newer revision→

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.

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 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

Template:Compu-soft-stubes:Pragma