I can use __LINE__
as a method parameter just fine, but I would like an easy way to use it in a function that uses strings.
For instance say I have this:
Yes, it's ugly. You need a combination of macros. Converting an integer to a string is a two-step process - here's Boost's implementation:
#define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X)
#define BOOST_DO_STRINGIZE(X) #X
Now you can generate a string:
logError(__FILE__ BOOST_STRINGIZE(__LINE__) "testcondition failed");