Proper C++ macros?
I just found this in the ht://Dig source code:
I had no idea you could do that. A function defined as a macro, that actually returns something.
So will the following work?
Didn't know that C++ would let you do this sort of thing...
Update: I tried it and it works:
(It prints "a = 3, b = 2").
... more like this: [Blog Search, C++]
#define encodeInput(name) (s = input->get(name), encodeURL(s), s.get())
I had no idea you could do that. A function defined as a macro, that actually returns something.
So will the following work?
int b;
int a = (b = 3, b += 1, b + 1);
Didn't know that C++ would let you do this sort of thing...
Update: I tried it and it works:
#include <stdio.h>
int main()
{
int a;
int b = (a = 1, ++a, a++);
printf("a = %d, b = %d\n", a, b);
}
(It prints "a = 3, b = 2").