Coding style question

From: Kinkie <gkinkie_at_gmail.com>
Date: Tue, 21 Aug 2012 07:08:13 +0200

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
Received on Tue Aug 21 2012 - 05:08:21 MDT

This archive was generated by hypermail 2.2.0 : Tue Aug 21 2012 - 12:00:06 MDT