Definition


Part of the pre-processor that you can pass arguments to macros

#define ODD(x) ((x) % 2 != 0)

void foo(){
	if (ODD(5))
		PRINTF ("5 IS ODD!\\N");
}

// is equivalent to: 
void foo(){
	if (ODD(5))
		PRINTF ("5 IS ODD!\\N");
}

Beware of operator precedence issues!

//Beware of ouerator precedence issues
//use parentheses
#define ODD(x) ((x)%2!=0)
#define WEIRD(x) x%2!=0

ODD(5+1);
WEIRD(5+1);

// would be translated to: 
((5+1)%2!=0);
5+1%2!=0; // WE DON'T WANT THIS!