Re: Woo hoo ... a whole new set of compiler headaches!!
От | Neil Conway |
---|---|
Тема | Re: Woo hoo ... a whole new set of compiler headaches!! |
Дата | |
Msg-id | 426BA0F3.1060100@samurai.com обсуждение исходный текст |
Ответ на | Re: Woo hoo ... a whole new set of compiler headaches!! (Alvaro Herrera <alvherre@dcc.uchile.cl>) |
Список | 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 по дате отправления: