Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can have it both ways!

  #ifdef FOO_BUILD_TIME_FLAGS
  #define foo_enabled(CTX, FLAG) ((FOO_BUILD_TIME_FLAGS & (FLAG)) != 0)
  #else
  #define foo_enabled(CTX, FLAG) (((CTX)->flags & (FLAG)) != 0)
  #endif
If we specify FOO_BUILD_TIME_FLAGS symbol which expands to a bitwise OR or various flags (or maybe just zero!) then the flag checks in the code all become constant expressions, subject to dead code elimination.

If we don't specify that, then there is a flags field that is checked at run-time.

I'd rather have most of the flags go away. Pick a behavior and hard-coded. Those who want it some other way can UTSL: use the source, Luke.

If you have 8 flags, that's 256 combinations to test for interactions.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: