Can the name of function and function-like macro be same?

c, macros

Solution

They could be the same. Depending on how you use the name, either it gets replaced by preprocessor or not. For example

//silly but just for demonstration.
int addfive(int n)
{
    return n + 5;
}
#define addfive(n) ((n) + 5)

int main(void)
{
    int a;
    a = addfive(2); //macro
    a = (addfive)(2); //function
}

for ex. MS says that: http://msdn.microsoft.com/en-us/library/aa272055(v=vs.60).aspx

Problem

Can the name of function and function-like macro be same? Wouldn't this cause any problem?

Original source

Related problems