Combine listings in different modules

I got some modules containing enumerations. (they contain signals that are used in the state machine).

moduleAsignals.h:

enum ModuleASignals {
  modASig1,   
  modASig2,   
  ...
  modASigN,   
};

moduleBsignals.h:

enum ModuleBSignals {
  modBSig1,   
  modBSig2,   
  ...
  modBSigM,   
};

Each module has an arbitrary number of signals.

Now I would like to combine a random selection of modules in one application. The problem is that all signals must be globally visible and that the signals must remain unique. There is also a limit on the size of one signal (8 bits), so I can’t just give unique offsets for the enumerations of individual modules.

enums ? - ( "enum... {" ) , , IDE , .

+3
2

, .h ,

enum ModuleBSignals {
  modBSig1 = modASigN+1,   
  modBSig2,   
  ...
  modBSigM,   
};

, .

:

:

#include "sig_start.h"  // Default one contains #define START 0

enum ModuleBSignals {
  modBSig1 = START,
...

sig_start.h . N + 1 th sig_start.h

#include module1signals.h
...
#include moduleNsignals.h
#define START modNSigM+1
+4

enum :

enum Signals {
#ifdef USE_MODULE_A
  modASig1,   
  modASig2,   
  ...
  modASigN,   
#endif
#ifdef USE_MODULE_B
  modBSig1,   
  modBSig2,   
  ...
  modBSigM,   
#endif
};

, IDE...

+2

All Articles