I wanted to have elif
as a macro for else if
by means of c++ Preprocessor
So that instead of writing like :-
if (something)
{
// Do something
}
else if (something else)
{
// Do something else
}
else
{
// Do something else
}
I could just write like :-
if (something)
{
// Do something
}
elif (something else)
{
// Do something else
}
else
{
// Do something else
}
This is what i tried :-
#define elif "else if"
But MinGW-w64 is Showing Error :-
error: expression cannot be used as a function
Help Please !?
The #define
preprocessing directive does not use quotation marks to delimit its replacement text. To define elif
to be replaced by else if
, simply use:
#define elif else if
That said, this would generally be regarded as a bad idea. C programmers become accustomed to the normal keywords that affect program control, and using customized keywords will confuse many people.