On Tue, 10 May 2011 17:33:57 +0200
Michael T <rasel...@hotmail.com> wrote:

> I was wondering if it is possible to improve the debugging information
> generated by gcc when resolving C macros? Just as an example, when I
> preprocessed the following C file:
> 
> extern int printf (__const char *__restrict __format, ...);
> 
> #define my_macro(i) \
>   do { \
>     *(i) = 1; \
>     *(i) += 2; \
>   } while(0)
> 

I am not a standard guru, but in my naive view this counts as one
single logical line (because backslash newline is handled by
preprocessing), so expansion of that macro invocation should be one
line also.

Besides, I believe that there are lots of actual C code which depends
upon that behavior. Code like
#define my_fatal_at(Msg,Line) do { \
  printf ("%s:%d fatal error: %s\n", __FILE__, Line, Msg); \
  abort (); \
} while(0); 

#define my_fatal(Msg) my_fatal_at(Msg,__LINE__)

My feeling is that with your proposal, the line number reported would
be wrong.

(I would image that both Linux Kernel's printk and Gtk g_assert might
behave similarily)

But maybe I didn't understood what you are proposing, or what the C
standards are saying. So I might be wrong.

Regards.

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***

Reply via email to