Stewart Stremler wrote:
This does seem to be my impression of a lot of code lately.  But then,
I loathe #ifdefs in code.  I'm just funny that way.

You are not alone.

One of the best articles I ever read was in C/C++ User's Journal talking about portable code and how to get rid of #ifdef's. The big one was to isolate the API to a single file which gets selected at *compile* time by the *build* system.

However, the "Aha!" moment was discussing some String function which was present in Windows but not in Linux (or vice versa). "Look, if you are going to have to write a substitute function for *one* OS, use it on *all* the OS's (ie. ignore the native one on Windows). The gain in being consistent across all the different build types, removing build specific code, testing the custom function everywhere and having everybody use the same code path far outweighs the efficiency gain of using the native function. Just comment *why* you are ignoring the native function so the next schmuck doesn't try to put it back in."

-a


--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to