Skip to content

Fix default UNITY_INCLUDE_EXEC_TIME macros - #849

Merged
mvandervoord merged 1 commit into
ThrowTheSwitch:masterfrom
Angel2Eyes:fix/838-unity-print-exec-time
Sep 6, 2026
Merged

Fix default UNITY_INCLUDE_EXEC_TIME macros#849
mvandervoord merged 1 commit into
ThrowTheSwitch:masterfrom
Angel2Eyes:fix/838-unity-print-exec-time

Conversation

@Angel2Eyes

@Angel2Eyes Angel2Eyes commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

🍍

Problem

UNITY_INCLUDE_EXEC_TIME cannot be used with -Werror=sign-conversion. On Windows the default UNITY_PRINT_EXEC_TIME assigns a signed clock_t delta to UNITY_UINT. Two of the three print macros are also brace blocks rather than statements, so MACRO(); is not if/else safe. CI never compiled this optional path, so it could rot.

Unix already uses clock_gettime(CLOCK_MONOTONIC) (with casts and do/while) when that clock exists. That path is unchanged.

Fix

  • Cast signed time deltas to UNITY_UINT and use do { } while (0) on the Windows and UNITY_CLOCK_MS print macros.
  • If Unix/macOS has no CLOCK_MONOTONIC in <time.h>, fall back to ISO C clock().
  • Add make execTimeDetection and run it from rake ci.

Closes #838.

Verification

  • unity.c compiles with MSVC with and without -DUNITY_INCLUDE_EXEC_TIME.
  • This environment has no gcc/make, so make test / rake ci were not run locally. GitHub Actions rake ci now includes execTimeDetection.

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
@mvandervoord
mvandervoord merged commit 43f5ce1 into ThrowTheSwitch:master Sep 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UNITY_PRINT_EXEC_TIME cannot be used with -Werror=sign-conversion

2 participants