Capturing caller's file/line number in variadic template functions

Steven Schveighoffer schveiguy at yahoo.com
Fri Mar 16 13:01:56 PDT 2012


On Fri, 16 Mar 2012 14:41:40 -0400, H. S. Teoh <hsteoh at quickfur.ath.cx>  
wrote:

> On Fri, Mar 16, 2012 at 02:30:25PM -0400, Steven Schveighoffer wrote:
> [...]
>> I know this is already answered, but do you get a stack trace?
>> Shouldn't the second stack frame point to the offending line?
> [...]
>
> I didn't compile with debugging turned on, so it only showed a hex
> address. Using compile-time args for __FILE__ and __LINE__ lets me see
> the offending line even when debug is off.
>
> (And actually, the offending line is several frames down; the top few
> frames look like unittest scaffolding the compiler inserted for catching
> assert errors and handling unittest-specific stuff. Kinda painful to
> figure out where the problem is if a straight error message will tell
> you immediately. :-))

Right, but I dislike this sort of boilerplaty stuff, especially for unit  
tests.  It should be avoidable...

-Steve


More information about the Digitalmars-d-learn mailing list