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

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Mar 16 11:41:40 PDT 2012


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. :-))


T

-- 
Indifference will certainly be the downfall of mankind, but who cares? -- Miquel van Smoorenburg


More information about the Digitalmars-d-learn mailing list