You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, the lack of an analog for C99's __func__ (aka __FUNCTION__ in GCC) leads to painful error-handling code at API boundaries (see below) as well as to inadvertent copy-paste errors since function names are hardcoded as string literals all over the place and it's easy to miss cases when the string isn't correct.
A concrete, simplified example from a C API that I'm developing, where we must write out the function name as a string literal once per each invocation of error handler:
pubexportfnfooCreateContext(version: u64, flags: u64, context: ?*foo.context) foo.status {
if (version>0) returnstatus.invalidArgument("fooCreateContext", "version");
if (flags!=0) returnstatus.invalidArgument("fooCreateContext", "flags");
if (context==null) returnstatus.invalidArgument("fooCreateContext", "context");
(Wherein status.invalidArgument in turn invokes a user-supplied error callback hook that needs to be able to report the function name whence the error originated.)
Right now, the lack of an analog for C99's
__func__
(aka__FUNCTION__
in GCC) leads to painful error-handling code at API boundaries (see below) as well as to inadvertent copy-paste errors since function names are hardcoded as string literals all over the place and it's easy to miss cases when the string isn't correct.A concrete, simplified example from a C API that I'm developing, where we must write out the function name as a string literal once per each invocation of error handler:
(Wherein
status.invalidArgument
in turn invokes a user-supplied error callback hook that needs to be able to report the function name whence the error originated.)Related issue: #2029
The text was updated successfully, but these errors were encountered: