When you see a line like:
#define IX(i,j) ((i)+(N+2)*(j))
is that equivalent to:
int IX(int i, int j) {
return ((i)+(N+2)*(j));
}
How do you know the return type etc?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Macros never get seen by the compiler – the preprocessor replaces the text.
So, when you write:
The compiler will see this:
This can have impacts on behaviour, but it depends on your macro. In this case, not so much (there are also performance and debugging differences, but let’s not worry about them here).
Had, for example, you defined your macro like this (note second use of i variable)
And called it like so:
Then the macro and function would have different behaviour.