So the more I work on pbstream (and I’m working on it quite a lot) the more obsessed I get with making it perfect. I’m no longer just out to just write some good software, my new goal is to utterly demolish this problem space with blindingly utter perfection. It’s going to be one of the best things I’ve ever done.
So my latest OCD goal this quest is to make it truly 100% C99 compliant: compilable on the weirdest and most nontraditional target, and free of any undefined behavior. I like most people have spent several years lulled into the x86/GCC monoculture. It’s time for me to transcend that narrow-minded view.
So I’ve set out to obtain every C compiler and lint tool I can possibly find, hoping that each one can show me even the smallest spot of imperfection that I can proceed to purge from my crystalline statements and declarations. I was ashamed to realize that I couldn’t even think of a time I had used a non-GCC/MSVC compiler in almost five years, and I didn’t know which ones were available to me. I am happy to say that I have eradicated some of that ignorance, and already have found some bugs that GCC didn’t show me!
So what C compilers are out there? Here are some of the ones I came across:
- Sun Studio, Sun's C and C++ compiler. To my surprise, it is available for free. Includes a lint tool.
- Intel C++ Compiler. You can obtain a non-commercial version for free if you absolutely, totally, cross-your-heart promise that you are not compensated in any way for your work. I have a vision of the Intel guys following around open-source developers at conferences and revoking them their non-commercial licenses at the first sign of any swag.
- Digital Mars C and C++ compiler, which is freely available for Windows and DOS.
- Visual C++ Express is a free download from Microsoft. Apparently has very poor C99 support though.
- The Portland Group has a C and C++ compiler, but there doesn't seem to be any way to use it without paying several hundred dollars.</a>
- Comeau has a C and C++ compiler that takes great pride in its standards-compliance. You just have to get over the curiously awful web page, which *actually says* "Bursting With So Much Language Support It Hurts!" No free use (though at $50, it's not a big hurdle -- I paid more for a parking ticket today. If only I hadn't had six such parking tickets to pay. For parking on my own street. But that's a story for another day). There is a web form (!) where you can paste your code and see error/warning messages though, which could be all you need to test standards-compliance.
- SDCC, the Small Device C Compiler is a GPL'd C compiler that targets tiny embedded processors. I was looking quite forward to this one as a target that is wildly different from other C compilers. Unfortunately, though it has partial C99 support, it does not support 64-bit integer types, and I'm not quite willing tilt at that particular windmill of making pbstream portable to compilers without 64-bit integer support.
- TCC, the Tiny C Compiler. Fabrice Bellard is an absolute bad-ass, but unfortunately TCC doesn't seem to support much of C99 (it choked on a for loop that defined a variable).
- Clang, the LLVM compiler. My version of Ubuntu doesn't seem to have this available, and I always find LLVM a bit of a pain to compile and install from source, but I would like to try this when I get the chance. </ul> So this should be enough variety that I can feel confident making smug assertions about pbstream's portability. Now the only question is whether I'll shell out $50 for the Comeau compiler just for that added potential for portability smugness.