Keil Logo Arm Logo

C251 User's Guide

#define

The #define directive defines a preprocessor macro.

#define macro-name 〚(arg〚, arg ...〛)〛 replacement-text

You may use #define to create function-like macros with or without arguments. Macros are syntactically similar to function calls. When a defined macro is encountered in the source file, the macro-name and any arguments are replaced by the replacement-text. For example:

#define my_macro(a,b,c) a+b+c

int func (int x, int y, int z)
{
return(my_macro(x,y,z));
}

appears as follows after macro expansion:

int func (int x, int y, int z)
{
return(x+y+z);
}

Refer to Macros for a complete description of how to define and use macros in your C programs.

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.