Re: [PATCH] a more efficient BUG() macro

Andrew Morton
2001-02-18T01:24:52Z

Keith Owens wrote:
>
> But ....
>
> a.h
> static inline void hello(void) { printf("%d at %s\n",__LINE__,__FILE__); }
>
> a.c
> #include <stdio.h>
> #include "a.h"
>
> int main()
> {
> hello();
> hello();
> return 0;
> }
>
> # ./a
> 1 at a.h
> 1 at a.h
>

__BASE_FILE__ does this. It expands to the thing which you
typed on the `gcc' command line.

bix:/home/morton> cat a.h
static inline void hello(void)
{
printf("%d at %s\n",__LINE__,__BASE_FILE__);
}
bix:/home/morton> cat a.c
#include <stdio.h>
#include "a.h"

int main()
{
hello();
hello();
return 0;
}

bix:/home/morton> gcc -O a.c
bix:/home/morton> ./a.out
3 at a.c
3 at a.c