I've been wondering: is it possible to distribute just the generated C sources for a Nim program? Or would that be bad?
Since Nim generates C89 code, wouldn't that make the resulting code very portable, other than the obvious architecture-dependent sections (a.k.a. Windows-x64, Windows-x86, Linux-PowerPC, etc.)?
I was just thinking how Nim distributes its own C sources.
That would probably work; I could just write a wrapper over it that generates files for all the target platforms.
Thanks!
The compiler generates backend-specific code for some C compilers; for example, it uses case x...y: for GCC and Clang to optimize case statements. You can find the definitions for the various compilers in compiler/extccomp.nim, with the props: TInfoCCProps field defining what a compiler is assumed to be capable of.
I think using --cc:ucc is the closest you'll get to ensuring the output is standard-compliant (with the caveat that certain things, such as conservative stack scanning, cannot possibly ever be standard-compliant, even though they're pretty much guaranteed to work on all existing C compilers).