ThrowTheSwitch / Unity

Simple Unit Testing for C
ThrowTheSwitch.org
MIT License
4.02k stars 969 forks source link

Cast line_num to allow compilation with `-WConversion` #721

Closed astro-stan closed 5 months ago

astro-stan commented 6 months ago

I wanted to compile my unit tests with -WConversion but it failed with:

...
MyRunner_Runner.c:95:35: error: conversion to ‘UNITY_UINT’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Werror=sign-conversion]
   95 |     Unity.CurrentTestLineNumber = line_num;
      |                                   ^~~~~~~~

Adding an explicit cast before fixes the problem.