On 2019-07-19 17:30, Newbie2019 wrote:
for example:
void ASSERT(string fmt, string file = __FILE_FULL_PATH__, size_t line =
__LINE__, T...) (bool c, scope T a) @nogc {
assert(c, string, file, line);
}
but i get this error:
error.d(39): Error: found file when expecting )
error.d(39): Error: found ) when expecting ; following statement
error.d(39): Deprecation: use { } for an empty statement, not ;
I want d to print the error message with some format information, and
show the right file and line for the original location.
Is it doable ?
No, not as far as I know. But you can throw an `AssertError` explicitly,
which is what `assert` does when it fails. This allows to pass the file
and line information [1]. Or call `onAssertError` which if called first,
when an `assert` fails [2].
[1]
https://github.com/dlang/druntime/blob/3620736bc88129b65f9a01290189de617a6c3b07/src/core/exception.d#L81-L84
[2]
https://github.com/dlang/druntime/blob/3620736bc88129b65f9a01290189de617a6c3b07/src/core/exception.d#L417-L449
--
/Jacob Carlborg