This is wrong.

It belongs in the linker and you can pull the symbol it creates in with extern. I’ve been doing this for about 25 years.

...and now your solution is non-portable and as a cross-platform developer you need to implement N different build scripts. This is far more elegant.

No C toolchain is portable!

If that's a problem, use Go or another higher level language.

Isn't one of the supposed advantages of C that it works on many platforms?

The last 40 odd years have proven that it does work but what you write isn’t portable.

That’s not the case, if you take a bit of care. Look at STB for example (https://github.com/nothings/stb) -- I’ve successfully used STB functions on a bunch of different platforms. In both C and C++, even!