On 01/16/2015 07:01 PM, enh wrote: > thanks for changeset 1661:d4bc084916fd "id.c #ifdefectomy. (ifdefs > belong in headers, not in C code.)". at the time i wrote the change > that applied to i thought "i know the style is to avoid #if, but i'm > not sure what that's supposed to look like here", and now i have an > example. (in particular, it wasn't clear to me that it's okay to add > stuff to portability.h to support this style.)
You can't always entirely avoid the ugly, but you can at least contain it. :) I rely on the compiler having basic dead code elimination, at least to drop out unnecessary function calls guarded by a test on a constant. Turbo C did this much back in 1990, C99 requires certain forms of compile-time constant propagation/evaluation to initialize global variables without generating code, and building the kernel also depends on unused functions dropping out. But calling a function requires a prototype these days, and if you haven't got the header... Rob _______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
