Takanobu Maekawa wrote:

>Hi gurus,
>
>I'm making a log function for debug.
>
>Like C/C++,I want to output the file name and line number
>at the place the log procedure called.
>I have ever done in C/C++  with __LINE__, __FILE__, __FUNC__ macros,
>as you know.
>
>Are there the same elements like this in Curl ?
>
>  
>
Not exactly, but you can get some of this same information using macros.
Macros can examine the CurlSource objects at compile time to determine
the line and file where the macro is expanded but there is no way to get
the current function at compile time other than to parse the source.

I haven't actually tried running this example, but I think that this
should give you the idea:

{define-macro {output-url-and-line ?src:tokens}
let url:url = tokens.url
let line:int = {tokens.get-line-and-column tokens.start-location}
{return
{expand-template
{output ?{Literal url.name & ":" & line}}
}
}
}

In 4.0, there will be way to determine the class through in
'define-syntax' macros through the
magic syntax-env variable, but not way to get the current function.

At runtime, you can use get-backtrace to get information, but we don't
make any guarantees about the format or content of the backtrace so I
would only use that as a last resort.

- Christopher


*******************************************
To unsubscribe from this list, send a mail to:
mailto:[EMAIL PROTECTED]
To contact a human list administrator, send a mail to:
mailto:[EMAIL PROTECTED]
To recieve a list of other options for this list, send a mail to:
mailto:[EMAIL PROTECTED]

Reply via email to