is this possible

It happened again.

I have many cases of modules with something like
#ifdef TYPEA
... many lines
#endif
#ifdef TYPEB
... many similar lines
#endif
#ifdef TYPEC
... many similar lines
#endif

It happens that I am looking at the type b code trying to figure out something in type a (the codes are VERY similar).

To avoid this, I have tried

blah,blah // comment TYPEA

and that "kind of works"

Now, the ideal would be if for type a I could do the following:
#ifdef TYPEA
#define ATYPE
#define BTYPE //
#define CTYPE //
#endif

and then just make it
ATYPE blah,blah // comment

Of course this does not work.
Does anyone have a trick that makes this possible?

Erik

Parents
  • I would strongly recommend putting this stuff in three different files instead.

    If you really want to keep on putting all these in a single file, you'll have to encapsulate statements, not blocks or lines:

    --- a.c ---
    #define TYPE_A(x) x
    #define TYPE_B(x) /* nothing */
    #define TYPE_C(x) /* nothing */
    #include "abc.c"

Reply
  • I would strongly recommend putting this stuff in three different files instead.

    If you really want to keep on putting all these in a single file, you'll have to encapsulate statements, not blocks or lines:

    --- a.c ---
    #define TYPE_A(x) x
    #define TYPE_B(x) /* nothing */
    #define TYPE_C(x) /* nothing */
    #include "abc.c"

Children
More questions in this forum