Keil Logo

#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.

  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.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.