Fix default UNITY_INCLUDE_EXEC_TIME macros - #849
Merged
mvandervoord merged 1 commit intoSep 6, 2026
Conversation
The timer helpers were untested, so they failed -Wsign-conversion on Windows and were not statement-safe. Unix still uses clock_gettime when CLOCK_MONOTONIC exists; otherwise it falls back to ISO C clock(). Resolves: ThrowTheSwitch#838
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.
🍍
Problem
UNITY_INCLUDE_EXEC_TIMEcannot be used with-Werror=sign-conversion. On Windows the defaultUNITY_PRINT_EXEC_TIMEassigns a signedclock_tdelta toUNITY_UINT. Two of the three print macros are also brace blocks rather than statements, soMACRO();is notif/elsesafe. CI never compiled this optional path, so it could rot.Unix already uses
clock_gettime(CLOCK_MONOTONIC)(with casts anddo/while) when that clock exists. That path is unchanged.Fix
UNITY_UINTand usedo { } while (0)on the Windows andUNITY_CLOCK_MSprint macros.CLOCK_MONOTONICin<time.h>, fall back to ISO Cclock().make execTimeDetectionand run it fromrake ci.Closes #838.
Verification
unity.ccompiles with MSVC with and without-DUNITY_INCLUDE_EXEC_TIME.make test/rake ciwere not run locally. GitHub Actionsrake cinow includesexecTimeDetection.