3 ms·
You can get pretty far with a compiler warning like "warn if a global isn't preceded by an 'extern' declaration". Also, LTO does have enough information to warn
by astrange 5y ago
You can get pretty far with a compiler warning like "warn if a global isn't preceded by an 'extern' declaration". Also, LTO does have enough information to warn about these things, especially with default hidden visibility.
- ericbarrett 5y agoThe global must be declared without "extern" somewhere or else no memory is allocated for it. LTO could handle this if you're compiling an executable, but not a library.
- astrange 5y ago> LTO could handle this if you're compiling an executable, but not a library. That's not the correct distinction, that's why I said default vs hidden visibility. Libraries typically export more symbols but executables can also export them eg for plugins.