Re: Woo hoo ... a whole new set of compiler headaches!!

From: Neil Conway <neilc(at)samurai(dot)com>
To: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: Dave Held <dave(dot)held(at)arrayservicesgrp(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Woo hoo ... a whole new set of compiler headaches!!
Date: 2005-04-24 13:36:51
Message-ID: 426BA0F3.1060100@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera wrote:
> We have plenty of very ugly macros anyway. See fastgetattr(),
> HeapKeyTest(), HeapTupleSatisfies(), HeapTupleHeaderSetXmax and friends,
> Assert() and friends.

I don't think Assert() is too bad, but I agree some of the others are a
bit ugly. In some places where we would like to use a macro but don't
want to doubly-evaluate macro arguments, we define the function with
"static inline" in a header file when using GCC, and include a normal
function definition in a source file otherwise (see list_length() in
pg_list.h / list.c for example). Needless to say, this is even uglier :)

An alternative would be to define inline functions in headers using
"static __inline". When using GCC (or other compilers that implement
sane "static inline" semantics per C99, such as icc), __inline would
expand to "inline"; otherwise it would expand to the empty string.
Compilers that don't implement "static inline" would include multiple
copies of the function definition, which would bloat the object code (if
a compiler doesn't implement "static", it is a good bet that it also
doesn't implement the unit-at-a-time analysis required to elide unused
static function definitions). So I'm not really sure that this is a win
overall.

-Neil

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message John Hansen 2005-04-24 14:09:08 Re: [HACKERS] UNICODE/UTF-8 on win32
Previous Message Bruce Momjian 2005-04-24 12:50:28 Re: [HACKERS] UNICODE/UTF-8 on win32