Hi all,
  as I'm refactoring things around (currently hacking protos.h to
pieces), I often encounter constructs such as:

.h file:
#if OPTIONAL_FEATURE
extern void someFunction();
#endif

.cc file:
#if OPTIONAL_FEATURE
void someFunction() {
  //code
}
#endif

client code:
#if OPTIONAL_FEATURE
  someFunction(arg);
#endif


I'm wondering if it wouldn't be more readable to transform this pattern into:
.h file:
extern void someFunction();

.cc file:
#if OPTIONAL_FEATURE
void someFunction() {
  //code
}
#else
void someFunction() {
  nop(); return;
}
#endif

client code:
  someFunction(arg);


The runtime cost would be negligible (if any), but it'd turn the code
into much less of a spaghetti.
What do you think?


-- 
    /kinkie

Reply via email to