2 ms·
> It is useful when you have a function defined in a header file, because if included in several source files, it will be present in multiple object files, and
by lelanthran 3y ago
> It is useful when you have a function defined in a header file, because if included in several source files, it will be present in multiple object files, and without "inline" the linker will complain of multiple definitions.
Traditionally you'd use `static` for that use case, wouldn't you?
After all, `inline` can be ignored, `static` can't.
- pjmlp 3y agoNo, because that would make it internal to each object file, while what you want is for all object files to see the same memory location.
- lelanthran 3y ago> No, because that would make it internal to each object file, while what you want is for all object files to see the same memory location. I can see exactly one use for an effect like that: static variables within the function. Are there any other uses?
- pjmlp 3y agoGlobal variables and the magic of a build system based on C semantics.