I'd like to create a C++ macro function to debug, and I'd like it to work like this:
int main(){
int a = 3, b = 5, c = 7;
string s = "<";
print(a,s,b);
print(a,s,b,s,c);
}
OUTPUT:
3 < 5
3 < 5 < 7
I've read a lot about variadic macros but anything I tried to code wouldnt work at all.
I thought about using lambda but didn't come up with algorithm to do it.
I need it like 1 line of code, cos it's just for debugging and more than that I could create a more complex function, but I guess this must be possible...
std::string. Lambdas are a runtime thing too. Macros are for preprocessing, prior to any compilation, leave alone runtime.abccan be treated like#abcthen it is something from the preprocessor.char*cannot do this either.intcannot be accessed form the preprocessor either. You could write some analyzer program to figure out the values of variables at a certain period of time within the execution of the program or just use a debugger or something that works at runtime. The C preprocessor has its limitations. m4 is a nice alternative that might come in handy here.