Commit 0c89d62
committed
fix(core): Ensure correct function linkage for C/C++ compatibility
This commit fixes a critical linkage bug that caused "undefined reference"
errors when compiling with a C++ compiler (G++), even though the same
code compiled successfully with a C compiler (GCC).
The root cause is a divergence in how `inline` is handled by standard
C++ versus the common GNU C compiler dialect.
In C++, an `inline` function's symbol is not guaranteed to be emitted if
all its uses within a translation unit are successfully inlined. This
caused other object files, which needed to call the function, to fail at
the linking stage.
The C compilation was succeeding due to a non-standard GCC extension where
a plain `inline` definition also generates a linkable external symbol.
This behavior is not guaranteed by the C99/C11 standards and masked the
portability issue.
By removing the `inline` keyword from the function definition inside the
`#ifdef TEC_IMPL` block, the function becomes a standard, non-inline
function. This guarantees that one globally visible symbol is generated,
ensuring correct and portable linking for both C and C++ compilers.
REFERENCES:
- https://en.cppreference.com/w/c/language/inline.html
- https://en.cppreference.com/w/cpp/language/inline.html
- https://gcc.gnu.org/onlinedocs/gcc/Inline.html
Signed-off-by: Shashwat Agrawal <shashwatagrawal473@gmail.com>1 parent da4d548 commit 0c89d62
2 files changed
+24
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
567 | | - | |
| 567 | + | |
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
| |||
575 | 575 | | |
576 | 576 | | |
577 | 577 | | |
578 | | - | |
| 578 | + | |
579 | 579 | | |
580 | 580 | | |
581 | 581 | | |
| |||
0 commit comments