Hacker News new | past | comments | ask | show | jobs | submit login

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?



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


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




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

Search: