Re: question about `static inline` functions in header files

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: question about `static inline` functions in header files
Дата
Msg-id 374910.1658459023@sss.pgh.pa.us
обсуждение исходный текст
Ответ на question about `static inline` functions in header files  (Junwang Zhao <zhjwpku@gmail.com>)
Ответы Re: question about `static inline` functions in header files  (Junwang Zhao <zhjwpku@gmail.com>)
Список pgsql-hackers
Junwang Zhao <zhjwpku@gmail.com> writes:
> I notice that there are lots of *static inline functions* in header files,
> the header file's content will go into each translation unit at preprocess
> phase, that means all the c file including the header will have a copy
> of the static inline function.

We are assuming that the compiler will not emit unused static functions.
This has been default behavior in gcc for ages.  If you're unfortunate
enough to have a compiler that won't do it, yes you're going to have a
bloated binary.

> IMHO, the header files should only include the inline function's declaration,
> and the definition should be in c files.

Then it couldn't be inlined, defeating the purpose.

            regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: John Naylor
Дата:
Сообщение: Re: some aspects of our qsort might not be ideal
Следующее
От: Fujii Masao
Дата:
Сообщение: Re: postgres_fdw: Fix bug in checking of return value of PQsendQuery().