Subject: Re: kernel panic messages
To: NetBSD Kernel Technical Discussion List <>
From: Ian Piumarta <>
List: tech-kern
Date: 05/04/2003 22:37:38
On Sun, 4 May 2003, Greg A. Woods wrote:

> 	#define panic(varags)	{ _panic_setup(__FILE__, __LINE__); _panic varargs; }
> 	panic(("help! %s", message));

I used to do error messages like that until I got fed up of typing all
those parens.  These days I prefer something like this...

#include <stdio.h>
#include <stdarg.h>

const char   *_panic_file= 0;
unsigned int  _panic_line= 0;

void _panic(const char *fmt, ...)
  va_list ap;
  va_start(ap, fmt);
  printf("%s:%d: ", _panic_file, _panic_line);
  vprintf(fmt, ap);

#define panic	(_panic_file= __FILE__, _panic_line= __LINE__, _panic)

int main()
  panic("help! %d", 42);
  return 0;

...which (ANSI prototypes notwithstanding) works with even the most
ancient of C compilers.