Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A16-0-1 Use #define for conditional file inclusion?
#1
Hi,

It's not clear if A16-0-1 allows using #define exclusively for creating header guards, or also for conditional file inclusion. Could you comment on that?

Example:

Code:
// foo.h
#if defined (SOMETHING) && !defined (SOMETHING_ELSE)  // Complex logic that we don't want to repeat everywhere
  #define SHOULD_INCLUDE_A              // Violating A16-0-1?
#else
  #define SHOULD_INCLUDE_B              // Violating A16-0-1?
#endif

// bar.h
#if   defined (SHOULD_INCLUDE_A)
  #include "bar_a.h"
#elif defined (SHOULD_INCLUDE_B)
  #include "bar_b.h"
#endif

// baz.h
#if   defined (SHOULD_INCLUDE_A)
  #include "baz_a.h"
#elif defined (SHOULD_INCLUDE_B)
  #include "baz_b.h"
#endif

Thanks!
Reply


Messages In This Thread
A16-0-1 Use #define for conditional file inclusion? - by cgpzs - 25-03-2022, 01:57 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)