Re: Woo hoo ... a whole new set of compiler headaches!! - Mailing list pgsql-hackers

From Neil Conway
Subject Re: Woo hoo ... a whole new set of compiler headaches!!
Date
Msg-id 426BA0F3.1060100@samurai.com
Whole thread Raw
In response to Re: Woo hoo ... a whole new set of compiler headaches!!  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
List 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


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [pgsql-hackers-win32] UNICODE/UTF-8 on win32
Next
From: "John Hansen"
Date:
Subject: Re: [pgsql-hackers-win32] UNICODE/UTF-8 on win32