This section contains 581 words (approx. 2 pages at 300 words per page) |
A macro is a name or identifier that represents a (usually larger) combination of other names, identifiers, or symbols. Typically these represented identifiers will be a list of commands or program code. Macros have two similar but subtly different interpretations, and which one is used depends chiefly on the program interpreting it.
The simplest kind of macro is what might be called a "substitution macro." This type of macro is found in programming languages like C and C++, which support a "pre-processor" stage immediately before the compiler proper takes over to turn the computer program into a form the computer can understand. In these languages a macro is defined like this:
- #define MY_MACRO printf("this is my macro!");
This line tells the pre-processor to replace every occurrence of the text "MY_MACRO" it finds in the code with the expression printf("this is my macro!"). This means...
This section contains 581 words (approx. 2 pages at 300 words per page) |