i am reffiring one gstreamer plugin code and i came to know in .h file they have written some following type function in .h file
static inline GstByteReader *
gst_ebml_read_br (GstEbmlRead * ebml)
{
g_return_val_if_fail (ebml->readers, NULL);
g_return_val_if_fail (ebml->readers->len, NULL);
return &(g_array_index (ebml->readers,
GstEbmlMaster, ebml->readers->len - 1).br);
}
you can see here its source
http://gstreamer.freedesktop.org/data/coverage/lcov/gst-plugins-good/gst/matroska/ebml-read.h.gcov.html
Edit : all function in that files are static inline
C compilers aren’t necessarily capable of inlining functions at link time. Therefore, if you actually want to give the compiler the best chance of inlining the function there must be a definition of the function in every TU that uses it. So it needs to be defined in the header file.
inlineallows the program to have multiple definitions of a function in different TUs.Additionally, this function is marked
static, giving it internal linkage and meaning that each TU has its own separate copy of the function.