4 ms·
Interesting read but IMHO fairly irrelevant for language users. I've been coding in C and C++ for more than 25 years and never encountered intmax_t or any probl
by flohofwoe 6y ago
Interesting read but IMHO fairly irrelevant for language users. I've been coding in C and C++ for more than 25 years and never encountered intmax_t or any problems related to it.
It's better to accept that C (and C++) are only portable in theory, in reality it's nearly impossible to write non-trivial code which compiles without warnings in a different compiler or runs out of the box on a different hardware architecture (still the language does a pretty good job at it everything considered). IMHO the standard committees should focus on the (handful) platforms that exist today, and not care too much about legacy or future platforms. The C standard shouldn't be some "pure ideal", just harmonize the differences between compilers and platforms, and only so far as it makes sense for real-world code.
Personally I'd rather see extensions from gcc and clang moved into the standard which are already battle proven instead of wasting time fixing 30 year old problems.
- jcelerier 6y ago> Personally I'd rather see real-world extensions from gcc and clang moved into the standard which are already battle proven instead of wasting time fixing 30 year old problems. there's nothing that prevents you from using clang on all platforms, which will be exactly the same experience that if you used $LANG_WITHOUT_AN_ISO_STANDARD
- flohofwoe 6y agoOh but there is :) As a library author I really don't want to dictate users what compiler to use, they should at least be free to choose between the "big 3": gcc, clang and MSVC. Having those 3 compilers agree on more language features would be very helpful (this doesn't even need to happen through the standard, it would be enough if gcc, clang and MSVC would agree on a handful of important non-standard extensions).
- enriquto 6y agoicc is arguably bigger than msvc (which is not even a modern C compiler)
- saagarjha 6y agoThankfully, it will be soon: https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/ https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-...
- enriquto 6y agohmmmm, no complex numbers, no vla... not really what many people call modern C nowadays.
- saagarjha 6y agoDo people actually use those?
- kevin_thibedeau 6y agoVLAs are a bad idea and nobody doing modern C should be touching them. It's alloca() magic and introduces all sorts of stack destroying risk.
- jcelerier 6y ago> Oh but there is :) As a library author I really don't want to dictate users what compiler to use, sure, there's nothing wrong with self-inflicted pain. Rust shows that a compiler monoculture works much better in practice.
- pjmlp 6y agoWhen everything you need is Linux.
- jcelerier 6y agoI use a clang/libc++ toolchain to target Linux, macOS and Windows - works like a charm. It's also the toolchain used by Android and iOS, and I could also do some WASM with it. So portability here is definitely not an issue to me
- pjmlp 6y agoA small portion of operating systems and CPUs available in the market. I thought the message was about everyone not your bubble.
- jcelerier 6y agoc'mon, clang is able to target x86&64, ARM, AArch64, MIPS, AVR, RISC-V, WASM among others - those combined are 99.9% of the market (and 100% of the market for desktop apps).
- pjmlp 6y agoAmong others is still a smaller pie than either GCC or vendor specific compilers on embedded systems CPUs and operating systems.
- pjmlp 6y agoOther than the little fact that there isn't clang on all platforms, nor everyone supports it properly on their platforms even when available.
- saagarjha 6y ago> It's better to accept that C (and C++) are only portable in theory, in reality it's nearly impossible to write non-trivial code which compiles without warnings in a different compiler or runs out of the box on a different hardware architecture It’s not that hard, unless you’re using -Wall or similar. And usually a platform that warns about something is probably giving decent advice anyways, regardless of whether the warning shows up elsewhere.
- flohofwoe 6y agoOf course. I guess what I wanted to say is: There's no way around testing your code on all compilers and platforms where that code is expected to run. There will always be new warnings and unpexted portability problems. Fixing those makes the code more robust. The language standard can only help a limited amount.
- loeg 6y ago> Interesting read but IMHO fairly irrelevant for language users. I've been coding in C and C++ for more than 25 years and never encountered intmax_t or any problems related to it. 15 years and ditto. I've only used it and seen it used for printf with %j, because that sucks less than the C99 PRIxBLAH conversions. > It's better to accept that C (and C++) are only portable in theory, I don't agree with that at all, though.
- pjmlp 6y agoHaving maintained a "portable" C code based across HP-UX, Aix, DG/UX, Solaris, Linux, BSD and Windows NT/2000, yes it is portable in theory, with plenty of workarounds in practice.