4 ms·
GCC 10 has no problem building C code that uses gets(), even with the -std=c17 compilation flag. You get a warning at runtime, but that's it.
by AlexeyBrin 7y ago
GCC 10 has no problem building C code that uses gets(), even with the -std=c17 compilation flag. You get a warning at runtime, but that's it.
- pjmlp 7y agoGCC is one specific C compiler, it does not represent all of them.
- theamk 7y agoJust 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.
- pjmlp 7y agoThat 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.
- theamk 7y agoNo, 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.
- pjmlp 7y agoWell, from that point of view, it is also the real power of Cobol, Fortran, RPG, NEWP, Java, C#, Delphi.
- AlexeyBrin 7y agoI 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.