Re: Concatenated if and preprocessor

Liste des GroupesRevenir à l c 
Sujet : Re: Concatenated if and preprocessor
De : dan (at) *nospam* djph.net (Dan Purgert)
Groupes : comp.lang.c
Date : 14. Mar 2025, 14:44:59
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <slrnvt8cmr.2ff.dan@djph.net>
References : 1 2
User-Agent : slrn/1.0.3 (Linux)
On 2025-03-14, pozz wrote:
Il 13/03/2025 16:44, pozz ha scritto:
Consider this code:
 
if (cond1) {
...
} else if (cond2) {
...
} else if (cond3) {
...
}
 
I want to activate every single if with a macro preprocessor. All the
combinations are possible: only the first, only the second, only the
third, the first and second... and so on.
 
What's the best method to have a clean code that is always compiled
without errors?
>
You're right, a real example is better to define my problem.
>
I have a project that can be compiled in different ways, depending on
the final product model (it's an embedded platform, it's a material
device).
I have three models with different characteristics: MODEL_A, MODEL_B,
MODEL_C. Three different builds that are managed at compile time by
defining MODEL macro as MODEL_A, MODEL_B or MODEL_C.
>
For each model, I could have a different features set. FEATURE_1,
FUTURE_2, FUTURE_3, ...
>
#if MODEL == MODEL_A
#  define FEATURE_1   1
#  define FEATURE_2   0
#  define FEATURE_3   0
#elif MODEL == MODEL_B
#  define FEATURE_1   0
#  define FEATURE_2   1
#  define FEATURE_3   0
#elif MODEL == MODEL_C
#  define FEATURE_1   1
#  define FEATURE_2   1
#  define FEATURE_3   1
#endif


So are you saying that the features are potentially independent of the
models, or that "Model A" explicitly defines that only "FEATURE_1" is
available (and will never support the other two) ?

--
|_|O|_|
|_|_|O| Github: https://github.com/dpurgert
|O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1  E067 6D65 70E5 4CE7 2860

Date Sujet#  Auteur
13 Mar 25 * Concatenated if and preprocessor26pozz
13 Mar 25 +- Re: Concatenated if and preprocessor1David Brown
13 Mar 25 +- Re: Concatenated if and preprocessor1James Kuyper
13 Mar 25 +- Re: Concatenated if and preprocessor1Kaz Kylheku
13 Mar 25 +- Re: Concatenated if and preprocessor1bart
13 Mar 25 +* Re: Concatenated if and preprocessor3Tim Rentsch
14 Mar 25 i`* Re: Concatenated if and preprocessor2Lynn McGuire
14 Mar 25 i `- Re: Concatenated if and preprocessor1Tim Rentsch
13 Mar 25 +- Re: Concatenated if and preprocessor1James Kuyper
14 Mar 25 `* Re: Concatenated if and preprocessor17pozz
14 Mar 25  +- Re: Concatenated if and preprocessor1David Brown
14 Mar 25  +- Re: Concatenated if and preprocessor1Dan Purgert
14 Mar 25  +* Re: Concatenated if and preprocessor12Tim Rentsch
14 Mar 25  i`* Re: Concatenated if and preprocessor11Richard Harnden
14 Mar 25  i +* Re: Concatenated if and preprocessor9Tim Rentsch
14 Mar 25  i i`* Re: Concatenated if and preprocessor8Keith Thompson
14 Mar 25  i i +* Re: Concatenated if and preprocessor3Richard Harnden
14 Mar 25  i i i`* Re: Concatenated if and preprocessor2Tim Rentsch
15 Mar 25  i i i `- Re: Concatenated if and preprocessor1David Brown
14 Mar 25  i i +* Re: Concatenated if and preprocessor3Tim Rentsch
15 Mar 25  i i i`* Re: Concatenated if and preprocessor2Keith Thompson
15 Mar 25  i i i `- Re: Concatenated if and preprocessor1Tim Rentsch
15 Mar 25  i i `- Re: Concatenated if and preprocessor1David Brown
15 Mar 25  i `- Re: Concatenated if and preprocessor1Lawrence D'Oliveiro
14 Mar 25  +- Re: Concatenated if and preprocessor1Keith Thompson
15 Mar 25  `- Re: Concatenated if and preprocessor1James Kuyper

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal