FACTOID # 22: The top nations for per capita imports and exports tend to be very small.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Directive (programming)

A directive is an instruction to a programming language compiler about how to compile a program. Rather than providing code per se, a programmer uses a directive to modify how or even if code is compiled.


Overview

Directives are used in several relatively low-level languages such as assembly programming, C and C++. In assembly language, directives generally tell the assembler the target platform, delineate segments, and so on. In C++, directives are used for conditional compiling, macros and including other files.


Examples

C/C++

There are several preprocessor directives in C and C++. The following are a few examples, but do not illustrate every directive or every situation in which one might find them. Note the lack of semicolons at the end of the lines: directives are instructions to the preprocessor, not the compiler, and they follow their own language grammar and rules.

 #include <iostream> 

This is the most common form for most programmers. It instructs the preprocessor to read a file from disk and insert its contents into the source code file. In this case it reads the general I/O streams header from the compiler's standard header directory.

 #define PI (3.14159) cout << (2.0 * PI) << endl; 

Macros are, essentially, preprocessor variables that are expanded inline into the source code. This example defines a macro named PI that is expanded to 3.14159 everywhere it is found in the code. This is deprecated in most cases, as C and C++ both provide constants that are more efficient and provide strong typing.

 #if defined LINUX // Do some Linux stuff here #elif defined WINDOWS // Do some Windows stuff here #endif 

Another common directive, this generally is used for conditional compilation. This example shows a directive that chooses two sets of code to include in the preprocessor output depending on which operating system macro is defined.


  Results from FactBites:
 
Directive (programming) - Wikipedia, the free encyclopedia (332 words)
Directives are used in several relatively low-level languages such as assembly programming, C and C++.
There are several preprocessor directives in C and C++.
Note the lack of semicolons at the end of the lines: directives are instructions to the preprocessor, not the compiler, and they follow their own language grammar and rules.
2 Assembly Language Programming (1675 words)
As in most programming languages, an identifier must start with a letter (or an underscore) and may be followed by any number of letters, underscores, and digits.
Using these directives, you could mix variable declarations and assembly language instructions; however, for the present, your assembly language programs should consist of a group of variable declarations followed by a group of assembly language instructions.
Programs to be run in the ISEM environment should terminate their execution by executing the instruction ``ta 0''.
  More results at FactBites »


 
 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms, 1022, m