Le 31/01/2022 à 23:41, Junio C Hamano a écrit :
"Jean-Noël Avila via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:
+inline void die_for_incompatible_opt3(int opt1, const char *opt1_name,
+ int opt2, const char *opt2_name,
+ int opt3, const char *opt3_name)
+{
+ die_for_incompatible_opt4(opt1, opt1_name,
+ opt2, opt2_name,
+ opt3, opt3_name,
+ 0, "");
+}
I haven't seen a non-static inline function defined in a common
header files. Does this actually work? In my build, ld choked on
this one.
This is quite subtle: "inline" is just a hint to the compiler but the
compiler can choose not to inline, so there must be an external symbol
to link to (which is not the case with this code).
My tests and the CI builds went smoothly, so I guess all these compilers
luckily chose to inline, but not yours.
With "static", we ensure that either it is inlined or there is a static
function (in which case, this bit of code will be duplicated across
compilation units).