Re: [PATCH 4/5] config.c: add a "tristate" helper
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 8, 2021, 23:51 UTC
- Message-ID
- <xmqqtuogpc6f.fsf@gitster.g>
- In-Reply-To
- <875z0wicmp.fsf@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> I'd prefer to just make these "enum", which means we'll have the aid of > the compiler in checking all the callsites, as in the patch-on-top > (which I can squash appropriately, need to update the doc comments > though) at the end of this E-Mail.
I think enum is oversold by some people (not me). C Compilers won't do much when you use them interchangeably with int, simply because they are designed to be used that way, no?
If existing code used 0 as false and 1 as true, and it learns an "auto" value with a new definition,
#define TRISTATE_AUTO 2
without TRISTATE_{TRUE,FALSE} defined to 0 and 1, that would be a good place to stop. I'd be quite happy with that.