question about `static inline` functions in header files - Mailing list pgsql-hackers

From Junwang Zhao
Subject question about `static inline` functions in header files
Date
Msg-id CAEG8a3L3GTFq6F07cx+Y8qkX_CPTTOQu-27Gzxbi9b_S3s_1fw@mail.gmail.com
Whole thread Raw
Responses Re: question about `static inline` functions in header files
List 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 by date:

Previous
From: Kyotaro Horiguchi
Date:
Subject: Re: [PATCH v1] eliminate duplicate code in table.c
Next
From: Fujii Masao
Date:
Subject: Re: Remove useless arguments in ReadCheckpointRecord().