在 2025-10-31 08:04, Pali Rohár 写道:
I see. I did some experiments and seems that this works in C, but not in C++. Seems that in C it does not require non-inline definition if the function is not declared with extern. In C when it is declared with extern then it behaves same as in C++ without extern, and the function symbol is not emitted.
For the differences, see this table: (https://github.com/lhmouse/mcfgthread/wiki/Differences-between-GNU,-C99-and-C---%60inline%60) ----+-------------------------+---------------------------+------------------------- # | inline type | Out-of-line definition | Out-of-line definition | | existence | linkage ----+-------------------------+---------------------------+------------------------- 1.1 | C plain GNU inline [1] | Always | External 1.2 | GNU static inline | Only when inlining fails | Internal 1.3 | C GNU extern inline [1] | Never | 2.1 | C99 plain inline [2] | Never | 2.2 | C99 static inline | Only when inlining fails | Internal 2.3 | C99 extern inline [2] | Always | External 3.1 | C++ plain inline [3] | Only when inlining fails | External, vague [4] 3.2 | C++ static inline | Only when inlining fails | Internal 3.3 | C++ extern inline [3] | Only when inlining fails | External, vague [4] ----+-------------------------+---------------------------+------------------------- [1] In GNU C, `extern inline` applies only if every declaration has an explicit `extern`. [2] In C99, `extern inline` applies if any declaration has an explicit `extern` or has no `inline`. [3] In C++ `extern` is implied if static is not specified, except for member functions, apparently. [4] These may be emitted as `.weak` symbols on Linux and in `.linkonce` sections on Windows.`inline` without `static` is equivalent to `extern inline` in C++ (and `extern` has no effect) so I think the phenomena which you see are both 1.3 in this table.
Multiple non-vague external definitions will cause linker errors. -- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
