Messages in this thread | | | From | Keith Owens <> | Subject | Re: [PATCH] a more efficient BUG() macro | Date | Sun, 18 Feb 2001 12:47:17 +1100 |
| |
On Sun, 18 Feb 2001 12:33:35 +1100, Andrew Morton <andrewm@uow.edu.au> wrote: >__BASE_FILE__ does this. It expands to the thing which you >typed on the `gcc' command line. > >bix:/home/morton> ./a.out >3 at a.c >3 at a.c
But __LINE__ is wrong. Forget what I said about __C_FILE__ and __C_LINE__, __C_LINE__ would not work for inline functions. Looks like the best option is a combination of __BASE_FILE__ and function name.
a.h #define BUG() \ printf("kernel BUG in func %s, file %s\n",__FUNCTION__,__BASE_FILE__);
static inline void hello(void) { BUG(); }
a.c #include <stdio.h> #include <a.h>
int main() { hello(); hello(); return 0; }
# gcc -I`pwd` `pwd`/a.c -o a # ./a kernel BUG in func hello, file /home/kaos/a.c kernel BUG in func hello, file /home/kaos/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/
| |