User talk:Greaterakash

Macro definition and expansion There are two types of macros, object-like and function-like. Function-like macros take parameters; object-like macros do not. The generic syntax for declaring an identifier as a macro of each type is, respectively,

Note that the function-like macro declaration must not have any whitespace between the identifier and the first, opening, parenthesis.
 * 1) define
 * 2) define

Wherever the identifier appears in the source code it is replaced with the replacement token list, which can be empty. For an identifier declared to be a function-like macro, it is only replaced when the following token is also a left parenthesis that begins the argument list of the macro invocation. The exact procedure followed for expansion of function-like macros with arguments is subtle.

Object-like macros are conventionally used as part of good programming practice to create symbolic names for constants, e.g.

instead of hard-coding those numbers throughout one's code.
 * 1) define PI 3.14159

An example of a function-like macro is:

This defines a radians to degrees conversion which can be written subsequently, e.g. RADTODEG(34) or RADTODEG (34). This is expanded in-place, so the caller does not need to litter copies of the multiplication constant all over his code. The macro here is written as all uppercase to emphasize that it is a macro, not a compiled function.
 * 1) define RADTODEG(x) ((x) * 57.29578)