Barefoot_Monkey: k=MACRO(i,j)*A;
// expand MACRO to get:
// k=j=i/j*A
// k=j=8/2*5
// k=j=4*5
// k=j=20
// so both k and j are now 20
Wishbone: Okay, I've never encountered the macro function before. It makes absolutely no sense to me that the multiplication by A outside the macro call should influence the assignment taking place inside it. What an extraordinarily weird bit of functionality. But then I never learned C, my school taught programming using C++.
MACRO is not a function (persay) but instead an actual macro/preprocessor directive (I think it counts as one of those).
Basically, when you see
#define A 5
That means that every time the preprocessor sees "A" it replaces it with "5", BEFORE compiling.
So MACRO(i,j) becomes i=j/i , BEFORE compiling.
Macros are very useful (even though I almost always would suggest a typedef or an inline if you are doing anything more than a #ifndef), but they are also very difficult to debug and tend to do little but obfuscate code.