4 ms·
I haven't heard of "tentative definitions" before. Couldn't you just replace it with a regular declaration i.e. extern foo n1, n2; Is there any benefit of
by quietbritishjim 7y ago
I haven't heard of "tentative definitions" before. Couldn't you just replace it with a regular declaration i.e.
extern foo n1, n2;
Is there any benefit of tentative definitions over this?
- Twisol 7y agoI'm not certain, but the `extern` variant probably doesn't reserve space at compile-time; it just says "the linker will know where to find these". So resolving those symbols might need to wait until link-time. The tentative definitions probably do reserve space (and hence an immediately-known address), and the later true definitions just supply the initial value to put in that space.
- kazinator 7y agoYes; the "extern" is potentially confusing when the definition is located in the same file below. They usually inform the reader of the code to look in some other file for the definition, and usually appear in header files.