Re: elog with automatic file, line, and function

From: Neal Norwitz <nnorwitz(at)yahoo(dot)com>
To: peter_e(at)gmx(dot)net, pgsql-hackers(at)postgresql(dot)org
Subject: Re: elog with automatic file, line, and function
Date: 2001-03-20 01:44:11
Message-ID: 3AB6B5EB.21F2D551@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut wrote:
>
> It has been brought up that elog should be able to automatically fill in
> the file, line, and perhaps the function name where it's called, to avoid
> having to prefix each message with the function name by hand, which is
> quite ugly.
>
> This is doable, but it requires a C preprocessor that can handle varargs
> macros. Since this is required by C99 and has been available in GCC for a
> while, it *might* be okay to rely on this.
>
> Additionally, C99 (and GCC for a while) would allow filling in the
> function name automatically.
>
> Since these would be mostly developer features, how do people feel about
> relying on modern tools for implementing these? The bottom line seems to
> be that without these tools it would simply not be possible.

It is possible, however, the macros require an extra set of parentheses:

void elog_internal(const char* file, unsigned long line, ... );
#define ELOG(args) elog_internal(__FILE__, __LINE__, args)

ELOG(("%s error", string))

For portability to older compilers, you should probably not require C99.

Also, I'm not positive, but I think that varargs are not part of C++
yet.
However, they will likely be added (if not already in draft form).

Neal

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-03-20 03:09:45 Re: New version of contrib-intarray is ready !
Previous Message Larry Rosenman 2001-03-20 01:25:48 Re: elog with automatic file, line, and function