Here's what I'm trying to do.... to make a macro that will give it an error as a c-string, and it will give me a c-string with the line and file and the error, all put together. Then I can use that string to display, or whatever. Here's what I have:
...and for output I get this:Code:#include <iostream> using namespace std; #define FlagF(Line,File,Error) ( "Line " #Line ", File " File ", Error " Error ) #define Flag(Error) ( FlagF( __LINE__, __FILE__, Error ) ) int main() { cout << Flag( "Blah!" ) << endl; }
"Line __LINE__, File c:\documents and settings\evan ovadia\my documents\visual studio projects\combination\main.cpp, Error Blah!"
Why is it saying __LINE__? I stringized it, but it was supposed to stringize the line number AFTER __LINE__ did its job. Is there a way to make the precedence of __LINE__ higher than the stringizer operator? If there isn't, is there any way to make a macro like I tried to make?
Thanks!