Macros are built on the #define preprocessor.
Normally a #define would look like:
#define PI 3.142But, a macro would look like this.
#define SQUARE(x) x*xThe 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);
}
macro example.
| Top | Master Index | Keywords | Functions |