News for hackers. Stuff that matters.
Re:Brian's Rules for Writing Cross Platform 'C' Code (2008) by justincormack on Saturday June 14, 2014 @06:34AM (#7892507)
Kind of falls out of his using one compiler per platform. There tend to be few differences though unless you use something less standard (like ARM's C compiler).
Re:Brian's Rules for Writing Cross Platform 'C' Code (2008) by brianwski on Monday June 16, 2014 @10:37PM (#7902600)
Original author here. Yeah, my goal was cross platform APPLICATIONS where the first step is choosing your tools. I suppose if you are writing a library like OpenSSL that you want to compile with every last flavor of every last compiler the problem gets worse.

I stand by my guideline for applications.

Another way to think about it is if you want, use all your own custom compiler flags, then if you can manage to get your compiler flags set by a creative combination of BUILT IN compiler flags, that way your code will compile right out of the box correctly on all platforms. What I dislike is that out of the box the code compiles on zero platforms. Instead, you run a "configurator" program that sets all the cross platform flags correctly. If at all possible, write your code so that it self configures correctly with zero changes on all compilers and all platforms. Please notice the "if at all possible". I think if you are relatively careful and just use basic types this can be done easily. Is it really that amazingly hard to find a native "int32" and "int64" type using ifdefs on every platform/compiler?