1. Home
  2. Computing & Technology
  3. C / C++ / C#

Definition of Macro

By , About.com Guide

Definition: In C and C++, a Macro is a piece of text that is expanded by the preprocessor part of the compiler. This is used in to expand text before compiling.

#define VALUE 10

Everywhere that VALUE is used the number of 10 will be used instead.

int fred[VALUE];
This declares an array of 10 ints.

Note: It is customary to put macros in upper case to distinguish them from variables

Glossary:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Examples:
It is better to use constants with const instead of the #define macro.
Explore C / C++ / C#
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#
  4. Glossary
  5. Macro - Definition

©2009 About.com, a part of The New York Times Company.

All rights reserved.