4 ms·
> several c compilers are supported Which is completely different from assuming that emitted C automatically compiles and runs fine under any C compiler under
by coder543 5y ago
> several c compilers are supported
Which is completely different from assuming that emitted C automatically compiles and runs fine under any C compiler under the sun on any target platform, which seemed to be the implied assumption made by the person I was replying to. I definitely could have misinterpreted.
Regardless, my main point is that FPC already seems to support… pretty much everything, which is impressive. They’ve clearly done a lot of work on portability over the years.
- blizdiddy 5y agoC is an ISO standard. That's how it works when you code to the standard.
- coder543 5y agoI wish C were that simple and well defined. The C standard leaves a lot of UB/implementation specific behavior. Fully “standards-compliant” code that works on one compiler may behave in unexpected ways under another compiler, just due to differences in UB handling. And no, it is not trivial to write UB-free C code. Let’s say you are generating C code from your own programming language. Did you know that an infinite loop that doesn’t do anything might be ignored?[0] This materially changes the behavior of the input program in ways that most people wouldn’t expect. C can quickly go from “infinitely portable assembler for my cool new language” to “major source of confusion.” That’s before even discussing compiler bugs, which will unintentionally break all assumptions of well-behaved code. Rust has run into (and submitted fixes for) so many LLVM bugs over the years that caused silent miscompilation. Complex software tends to have bugs somewhere, and a lot of compilers are complex. The less trivial the C code, the more likely you are to run into compatibility problems between compilers. “Hello world” should reliably work everywhere, so that’s something… I guess. But that’s just like… my opinion. If generating arbitrary C code and shoving it through arbitrary C compilers works reliably for you, then that’s cool? I personally would want to see a large battery of tests that ensures the program code is likely to be working under each new compiler. [0]: https://stackoverflow.com/questions/59925618/how-do-i-make-an-infinite-empty-loop-that-wont-be-optimized-away https://stackoverflow.com/questions/59925618/how-do-i-make-a...
- mercurialuser 5y agoI understand what you say but FPC and Harbour just show that writing portable c code is actually possible... https://github.com/harbour/core#supported-platforms-and-c-compilers https://github.com/harbour/core#supported-platforms-and-c-co...