Add type-generic CHECK_EQUAL for C via C11 _Generic - #100
Merged
Conversation
Enable C as a project language and require c_std_11 as a public compile feature on the mutiny target, propagating the minimum to any consumer (mutiny_test, examples) that links against it. This lets test.h dispatch CHECK_EQUAL/CHECK_EQUAL_TEXT on the type of `actual`, as an additive alternative to the typed CHECK_EQUAL_* macros (which remain for double/memcmp and explicit use).
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a type-generic
CHECK_EQUAL/CHECK_EQUAL_TEXTtotest.h, dispatching on the type ofactualvia C11_Generic(bool/int/uint/long/ulong/longlong/ulonglong/char/ubyte/sbyte/string/pointer). The existing typedCHECK_EQUAL_*macros remain — they still back the dispatch, anddouble/memcmpkeep their dedicated macros since those take extra arguments_Genericcan't accommodate.To support this, the top-level
project()now declaresCalongsideCXX, andc_std_11is set as aPUBLICcompile feature on themutinytarget so the C11 minimum propagates to any consumer (tests, examples) linking againstmu::tiny, without touching each consumer'sCMakeLists.txtindividually.Note for reviewers: enabling
Cas a project language means a C compiler is now required at configure time even for consumers that only use the C++ API. Worth considering whether this warrants a version bump per the semver policy inCONTRIBUTING.md.Related Issues
N/A
Type of Change
Manual Verification (Optional)
Checklist
docs/for any user-facing changes.mu::tinynamespace,INCLUDED_MU_TINY_guards,mutiny_C-prefix)..hand.c.cpp) is required for parity.CONTRIBUTING.mdfile to ensure compliance with architectural guidelines.