# Macros

Macros are built on the #define preprocessor.

Normally a #define would look like:

    	#define PI 3.142

But, a macro would look like this.

    	#define SQUARE(x) x*x

The main difference is that the first example is a constant and the second is an expression. If the macro above was used in some code it may look like this:

            #define SQUARE(x)  x*x

            main()
            {
              int value=3;
              printf("%d \n", SQUARE(value));
            }

After preprocessing the code would become:

            main()
            {
              int value=3;
              printf("%d \n", value*value);
            }

## Examples:

macro example.

## Notes:

- The value passed to SQUARE could have been an int float or double
- Long macros can span multiple lines by using a \ followed by a newline (return).
- If you are using gcc to compile your code, you can use the -E option to see the preprocessor output

## See Also:

- #define preprocessor.
- inline A C++ keyword that provides a better aproch to macros.

Top | Master Index | Keywords | Functions