Skip to content

UNITY_PRINT_EXEC_TIME cannot be used with -Werror=sign-conversion #838

Description

@swaldhoer

unity.c cannot be compiled using -Werror=sign-conversion due to UNITY_PRINT_EXEC_TIME.

In file included from cmock/vendor/unity/src/unity.h:21,
                 from cmock/vendor/unity/src/unity.c:8:
cmock/vendor/unity/src/unity.c: In function 'UnityConcludeTest':
cmock/vendor/unity/src/unity_internals.h:395:33: error: conversion to 'UNITY_UINT' {aka 'long long unsigned int'} from 'clock_t' {aka 'long int'} may change the sign of the result [-Werror=sign-conversion]
         UNITY_UINT execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime); /
                                 ^
cmock/vendor/unity/src/unity.c:516:5: note: in expansion of macro 'UNITY_PRINT_EXEC_TIME'
     UNITY_PRINT_EXEC_TIME();
     ^~~~~~~~~~~~~~~~~~~~~
cc1.exe: all warnings being treated as errors

The macro needs to be fixed in src/unity_internals.h

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions