How to use __LINE__ in a string

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-04-19T20:56:19Z Indexed on 2010/04/19 21:03 UTC
Read the original article Hit count: 106

Filed under:
|
|

Just using it as a method parameter is fine but what about an easy way to use it in strings?

For instance say I have this:

11    void myTest()
12    {
13     if(!testCondition)
14       logError("testcondition failed");
15    }

And I want the output to be:

"myTest line 14: testcondition failed"

How can I write logError? Does it have to be some monstrosity of a macro?

© Stack Overflow or respective owner

Related posts about c++

Related posts about preprocessor