I need to understand how this code works:
#define foo1( a ) (a * a) // How does this work?
inline int foo2(
Macro is not a function. The compiler will expand all macros and then compile it. To see the expanded code, you can use the following command using -E option in gcc:
gcc -E
Or in Visual C++, under Configuration Properties->C/C++->Preprocessor, set "Generate Preprocessed File".
BTW, your macro is problematic. You should use
#define foo1( a ) ((a) * (a))
instead of
#define foo1( a ) (a * a)