Re: elog with automatic file, line, and function - Mailing list pgsql-hackers

From Pete Forman
Subject Re: elog with automatic file, line, and function
Date
Msg-id 15031.10250.607728.88980@kryten.bedford.waii.com
Whole thread Raw
In response to Re: elog with automatic file, line, and function  (Larry Rosenman <ler@lerctr.org>)
Responses Re: Re: elog with automatic file, line, and function  (Larry Rosenman <ler@lerctr.org>)
List pgsql-hackers
Larry Rosenman writes:> * Tom Lane <tgl@sss.pgh.pa.us> [010319 18:58]:> > However, if the C99 spec has such a concept,
theydidn't use that name> > for it ...> My C99 compiler (SCO, UDK FS 7.1.1b), defines the following:> Predefined names>
>The following identifiers are predefined as object-like macros: > > > __LINE__>     The current line number as a
decimalconstant. > > __FILE__>     A string literal representing the name of the file being compiled. > > __DATE__>
Thedate of compilation as a string literal in the form ``Mmm dd> yyyy.'' > > __TIME__>     The time of compilation, as
astring literal in the form> ``hh:mm:ss.'' > > __STDC__>     The constant 1 under compilation mode -Xc, otherwise 0. >
>__USLC__>     A positive integer constant; its definition signifies a USL C> compilation system. > > Nothing for
functionthat I can find.
 

It is called __func__ in C99 but it is not an object-like macro.  The
difference is that it behaves as if it were declared thus.
   static const char __func__[] = "function-name";

Those other identifiers can be used in this sort of way.
   printf("Error in " __FILE__ " at line " __LINE__ "\n");

But you've got to do something like this for __func__.
   printf("Error in %s\n", __func__);

-- 
Pete Forman                 -./\.- Disclaimer: This post is originated
WesternGeco                   -./\.-  by myself and does not represent
pete.forman@westerngeco.com     -./\.-  opinion of Schlumberger, Baker
http://www.crosswinds.net/~petef  -./\.-  Hughes or their divisions.


pgsql-hackers by date:

Previous
From: Philip Warner
Date:
Subject: Re: Re: Patch application
Next
From: Oleg Bartunov
Date:
Subject: Re: Re: FAQ: Current state of replication ?