Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #391166
| From | Dan Purgert <dan@djph.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Concatenated if and preprocessor |
| Date | 2025-03-14 13:44 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <slrnvt8cmr.2ff.dan@djph.net> (permalink) |
| References | <vquuhg$34o8d$2@dont-email.me> <vr15ti$rtjs$1@dont-email.me> |
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
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Concatenated if and preprocessor pozz <pozzugno@gmail.com> - 2025-03-13 16:44 +0100
Re: Concatenated if and preprocessor David Brown <david.brown@hesbynett.no> - 2025-03-13 16:55 +0100
Re: Concatenated if and preprocessor scott@slp53.sl.home (Scott Lurndal) - 2025-03-13 16:11 +0000
Re: Concatenated if and preprocessor James Kuyper <jameskuyper@alumni.caltech.edu> - 2025-03-13 12:07 -0400
Re: Concatenated if and preprocessor Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-13 16:30 +0000
Re: Concatenated if and preprocessor bart <bc@freeuk.com> - 2025-03-13 17:29 +0000
Re: Concatenated if and preprocessor Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-13 14:37 -0700
Re: Concatenated if and preprocessor Lynn McGuire <lynnmcguire5@gmail.com> - 2025-03-13 18:25 -0500
Re: Concatenated if and preprocessor Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-14 09:26 -0700
Re: Concatenated if and preprocessor James Kuyper <jameskuyper@alumni.caltech.edu> - 2025-03-13 12:19 -0400
Re: Concatenated if and preprocessor pozz <pozzugno@gmail.com> - 2025-03-14 13:02 +0100
Re: Concatenated if and preprocessor David Brown <david.brown@hesbynett.no> - 2025-03-14 14:13 +0100
Re: Concatenated if and preprocessor Dan Purgert <dan@djph.net> - 2025-03-14 13:44 +0000
Re: Concatenated if and preprocessor Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-14 09:44 -0700
Re: Concatenated if and preprocessor Richard Harnden <richard.nospam@gmail.invalid> - 2025-03-14 18:15 +0000
Re: Concatenated if and preprocessor Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-14 13:40 -0700
Re: Concatenated if and preprocessor Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-14 14:10 -0700
Re: Concatenated if and preprocessor Richard Harnden <richard.nospam@gmail.invalid> - 2025-03-14 21:31 +0000
Re: Concatenated if and preprocessor Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-14 15:29 -0700
Re: Concatenated if and preprocessor David Brown <david.brown@hesbynett.no> - 2025-03-15 17:32 +0100
Re: Concatenated if and preprocessor Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-14 15:57 -0700
Re: Concatenated if and preprocessor Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-14 16:27 -0700
Re: Concatenated if and preprocessor scott@slp53.sl.home (Scott Lurndal) - 2025-03-15 15:06 +0000
Re: Concatenated if and preprocessor Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-15 08:49 -0700
Re: Concatenated if and preprocessor scott@slp53.sl.home (Scott Lurndal) - 2025-03-15 17:28 +0000
Re: Concatenated if and preprocessor David Brown <david.brown@hesbynett.no> - 2025-03-15 17:28 +0100
Re: Concatenated if and preprocessor Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-03-15 07:03 +0000
Re: Concatenated if and preprocessor Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-14 11:10 -0700
Re: Concatenated if and preprocessor James Kuyper <jameskuyper@alumni.caltech.edu> - 2025-03-14 23:20 -0400
csiph-web