» Friday, 15 January A.D. 2010
grouchy c programmer
Whenever possible, feature macros in C should be #define'd to 0 or 1, rather than letting the definedness or lack thereof be the switch for the feature. This convention means that you can talk about the feature macro in conditions, rather than having to jump through hoops to do so. (Doing so also means that you can play clever tricks in code with said feature macros if need be...) Of course, this implies that your compiler needs to be intelligent about dead code elimination in the presence of disabled features, but what compiler isn't?
Also, to all the hotspot rockstar programmers out there who are enormously impressed with their ability to record key routines from the C library using whizbang vector instructions and cache control instructions and show massive speedups: please try to actually test your code to ensure that it has the same correctness properties as the code in the C library. Nobody cares how fast your routines are if they cause buffer overflows on real-world code, rather than the trivial benchmark you threw together.
posted by Nate @ 10:05PM