4 ms·
The reason for sticking to standard is when inevitably someone will try to compile it with another compiler. It’s far easier just to stick to the spec instead o
by sharpneli 5y ago
The reason for sticking to standard is when inevitably someone will try to compile it with another compiler. It’s far easier just to stick to the spec instead of fixing non standard code.
For some reason it has been me several times doing the fixing as original dev thought it’s completely fine. I hope to save others the pain.
- flohofwoe 5y agoIMHO the only practical solution to this problem is to compile and test the code at least on the popular compilers (e.g. GCC, Clang and MSVC), which is quite easy today with CI services like GH Actions. The standard also often doesn't tell what features are actually supported by different compilers (e.g. MSVC famously will never be C99 compliant, but eventually - really soon now! - C11 compliant) - so the language standard is in reality more like a recommendation of what features are more likely to work across compilers than others. Finally, even standard compliant code may still trigger a lot of warnings, and those warnings are different on different compilers or different versions of the same compiler, so testing on different compilers is needed anyway to cleanup warnings.
- pjmlp 5y agoMSVC is already C17 compliant, minus optional annexes.
- deleted 5y ago[deleted]
- int_19h 5y agoIt's not an either-or. Write standard-compliant code as much as possible, and test it with real-world compilers (and work around their quirks or limitations if needed). Somebody trying to compile it 20 years later will thank you.