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

> C99 requires that you at least declare a function before calling it

Where is that written? Please quote the standard. My reading of ISO/IEC 9899:TC3 is that Foreword says (paraphrasing) "hey, we removed implicit int and implicit prototypes from the standard". So they simply stopped specifying it, but as far as I can tell, the standard says nothing about forbidding them. From my point of view, that means compilers are free to still implement implicit types as a compiler extension to the language, and everyone does, because that extension is needed in order to support the older c89 standard. It would only impact people who want to be able to claim their codebase is c99 standard compliant, because you can't do that if you depend on compiler extensions.




> Where is that written?

ISO/IEC 9899:TC3 [1] §6.5.1 ¶2: "An identifier is a primary expression, provided it has been declared as designating an object (in which case it is an lvalue) or a function (in which case it is a function designator)."

There's even a footnote to underscore this point: "79) Thus, an undeclared identifier is a violation of the syntax."

[1]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf


Prototypes are required in C23 as part of the expungement of K&R syntax. This also brings harmonization with C++ where an empty parameter list is implicitly void.




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

Search: