3 ms·
> but it supports ancient K&R C syntax, without such goodies like subscript operator or character literals. Still I prefer ancient C than ancient assembly langu
by korethr 6y ago
> but it supports ancient K&R C syntax, without such goodies like subscript operator or character literals. Still I prefer ancient C than ancient assembly language
A thought occurs to me: would it be possible to use that compiler to bootstrap your way to a modern C dialect? At one point, there were no C89 compilers. So, one would have to write a C89 compiler in K&R. Or am I failing to appreciate just how much work it would be?
- duskwuff 6y ago> A thought occurs to me: would it be possible to use that compiler to bootstrap your way to a modern C dialect? You don't need to. SmallC is a cross-compiler, not a self-hosting compiler; it runs on a modern computer, not an 8085. If you wanted to modify SmallC to accept modern C syntax, you can do that without "bootstrapping" anything.
- arcticbull 6y agoYou could probably write some macros or some other kind of text processing job to convert modern C constructs into K&R and feed it into SmallC.
- kmeisthax 6y agoYou need to write a bridge compiler in C89 that can compile newer variants of C, and then feed another compiler's source code into it. These are implicitly written whenever new C features are added to compilers (can't depend on features that don't exist yet) but will be destroyed fairly quickly (why not dogfood our own features?). Furthermore, the compilers most people are going to want are either GCC or LLVM/clang, both of which have non-standard extensions which you'll likely also need to support. However, a much more efficient approach would be to add support for older architectures to a modern compiler. Then you can build binaries via cross-compilation, or cross-compile the compiler itself to get a modern self-compiler on an old system.
- pabs3 6y agoThese folks are working on bootstrapping from a small amount of machine code for multiple arches all the way to the Linux kernel. https://bootstrappable.org/ https://bootstrappable.org/