lkml.org 
[lkml]   [2001]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] a more efficient BUG() macro
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:15    [W:0.099 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site