question about `static inline` functions in header files

Поиск
Список
Период
Сортировка
От Junwang Zhao
Тема question about `static inline` functions in header files
Дата
Msg-id CAEG8a3L3GTFq6F07cx+Y8qkX_CPTTOQu-27Gzxbi9b_S3s_1fw@mail.gmail.com
обсуждение исходный текст
Ответы Re: question about `static inline` functions in header files  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
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.

The inline keyword is a hint for compiler to inline the function, if the
compiler does inline the function, the definition could be optimized out
by the compiler, but if the *inline function*  can not be inlined, the function
will reside in each of the translation units that include the header file, which
means the same static function compiled multiple times and may waste
some space?

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

I am not sure why this kind of coding style came along, appreciate if
some one can give me some clue, thanks :)

-- 
Regards
Junwang Zhao



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

Предыдущее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: [PATCH v1] eliminate duplicate code in table.c
Следующее
От: Fujii Masao
Дата:
Сообщение: Re: Remove useless arguments in ReadCheckpointRecord().