[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trace function

From: Salvatore Di Fazio
Subject: Re: Trace function
Date: 11 Jan 2007 04:58:20 -0800
User-agent: G2/1.0

Ulrich Eckhardt ha scritto:

> You mean 'function that called the Trace function' and not 'function that
> was called', right?

Yes I mean it... excuse me for my explaination :)

 > The typical solution for this is to create a macro that does the
job, e.g.
> like this:
>   #define TRACE(fmt, arg) Trace( "%s: "fmt, __FUNCTION__, arg)

I think that's enough, but the following is an interesting argument.

> If you need to use a variable number of arguments, this becomes a bit more
> tricky. IIRC, C99 introduces macros with a variable number of arguments,
> but I'm not sure about the syntax. Otherwise, in C++, you can use a
> temporary object:
>  struct tracer {
>    tracer( char const* file) { ... }
>    void operator()( char const* fmt, ...) const { TraceV(...); }
>  };
>  #define TRACE tracer(__FUNCTION__)

I will try that solution :)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]