I've been playing around with macros. I saw an interesting post where I can structure my macro in a function like structure here. I've tried to implement one and here is what I currently have.
#define Max(X,Y) \
do { \
auto var1 = x; \
auto var2 = y; \
var1 > var2 ? var1 : var2; \
} while (0)
and in my main function
void main()
{
int result = Max(10, 5)
}
but I'm getting all these errors,
error C2059: syntax error : 'do'
error C2143: syntax error : missing ';' before '{'
Not sure what I did wrong. I just copied the code from the hyperlink above and just modified the code. Any help would be greatly appreciated!