Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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.



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.


> 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?


Global variables and the magic of a build system based on C semantics.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: