File and line numbers in error messages

Greg Hudson ghudson at MIT.EDU
Wed Apr 29 17:37:58 EDT 2009

On Tue, 2009-04-28 at 16:14 -0400, Ken Raeburn wrote:
> Even without the gcc bits, if you have C99 support it's doable.

Right, by starting the variadic part at the format argument.  Got it.

> It's nitpicky, but I think I'd rather see "(get_in_tkt.c:1503)" added  
> at the end.

Okay, but it's only easy to make it appear at the end of the error message, not the "while brushing my teeth" part that com_err appends.

> I'd think for many UNIX builds you'd actually want the capability  
> compiled in, but turned off by default.

Currently leaning towards no on this, because it still adds static
strings to the library object files.  Using an #ifdef also removes the
need for an autoconf check for variadic macros ("if it hurts for you to
define DEBUG_ERROR_FILE_LINE, don't define it") but for posterity, the
autoconf check is pretty simple:

dnl Test for C99-style variable-argument macro support                          
AC_CACHE_CHECK(if compiler supports C99-style variadic macros,
#define macro(...) return(__VA_ARGS__)                                          
int main() { macro(1); }
], krb5_cv_variadic_macros=yes, krb5_cv_variadic_macros=no)])
if test "$krb5_cv_variadic_macros" = yes; then
  AC_DEFINE(HAVE_VARIADIC_MACROS,1,[Define if compiler supports C99-style variadic macros.])

> Then when someone reports [...]

As Sam pointed out, the onus is on us to make our error messages clear,
not rely on obscure features to support people who get unclear error

For similar reasons, I don't want to add a mkerr() and litter the code
with it at this time.

More information about the krbdev mailing list