Martin Sebor <msebor@xxxxxxxxx> writes: > On 11/09/2015 05:57 AM, Sergey Organov wrote: >> Hello, >> >> GCC, when compiling C code, seems to always generate out-of-line copy of >> any [C99] inline function that also happens to be a GCC builtin, >> resulting in link errors (see a test-case below). According to C99 >> standard, an out-of-line copy of a function should only be instantiated >> in those compilation unit(s) where the function is also declared >> 'extern'. >> >> Apparently, all builtin functions implicitly get 'extern' declaration that >> forces out-of-line copy of inline function in every compilation unit. >> >> Is it a bug of feature? If the latter, what is the way for a library to >> provide generic inline functions that might happen to be GCC builtins? > > Depending on the -std= option, GCC can generate a copy of an inline > function (regardless of whether or not the function also has a builtin > form) in each translation unit that defines it. To avoid multiple > definition errors, define inline functions in C headers as static. > > The following page explains how GCC treats the inline specifier > in each of the standard mode: > > https://gcc.gnu.org/onlinedocs/gcc/Inline.html The point is that for builtin functions it apparently does it wrong. -- Sergey.