Skip to content

Placing #ifdefs inside or outside of source files #452

Closed
@jackhumbert

Description

Mentioned in #451, I'd like to look at the possibility of moving a large portion of the

#ifdef FEATURE_ENABLE
  #include "feature.h"
  feature();
#endif

code blocks to having a wrapper on the entire feature.c file to disable it, and include dummy functions where necessary (they likely won't be needed that often).

Pros:

  • disable via config.h instead of Makefile (doesn't really cleaning, easier/more straight-forward to modify, all being c)
  • cleaner code, no giant #ifdefs around calls (something action.c is suffering from)
  • no #ifdefs required in keymap.c

Cons:

  • is the compiler smart enough to exclude things without affecting memory size?
  • code is less clear, since functions will always be called (unsure if they're doing anything)
  • feature.c will always be compiled (I believe) - does this have an effect on compile time?

Comments are welcome!

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions