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

GCC is one specific C compiler, it does not represent all of them.



Just checked on gotbolt.com - clangg, icc, msvc all compile gets just fine. They also work with k&r style definitions as well.

I am sure there are broken C compilers out there which don’t implement entire language. Heck, I use one sometimes. But I don’t think this proves your point at all.

You need better examples.


That only proves that those compilers are not willing to follow up on everything that the standard specifies.

Like always on the C and C++ community, "works on my compiler" and "what the standard states about it" is not the same.


No, those compilers would likely reject it, if I had activated c17 mode. But I did not -- so it worked.

This is a real power of C and C++ -- each file gets its own mode. That K&R library you made in ancient time? C++98 classes? All still works and links to the modern stuff. You can be sure that whatever code you wrote today would still be usable, possibly with minor modifications, 20 years later. Sure, the compiler names and build systems will change, but the code would work.


Well, from that point of view, it is also the real power of Cobol, Fortran, RPG, NEWP, Java, C#, Delphi.


I checked just GCC 10 and Clang 9, pretty sure MSVC will also let you use gets() since their C compiler is C89 with partial C99 support.

Honestly I would've expected an error with -std=c17 -Wall -pedantic from GCC and Clang since gets() was removed in the C11/C17 standards.




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

Search: