ofxMidi icon indicating copy to clipboard operation
ofxMidi copied to clipboard

explicit conversion : Just to get rid of warnings

Open dimitre opened this issue 2 years ago • 4 comments

not sure if its the best way

dimitre avatar Apr 05 '22 20:04 dimitre

What is the warning?

danomatika avatar Apr 05 '22 20:04 danomatika

Implicit conversion loses integer precision: 'unsigned long' to 'unsigned int'

dimitre avatar Apr 05 '22 20:04 dimitre

it can be supressed by #pragma GCC diagnostic ignored "-Wshorten-64-to-32"

dimitre avatar Apr 05 '22 20:04 dimitre

In general, suppression is a bad idea, better to fix the issue.

The issue is that the ticks member variable is an unsigned long while the functions work with unsigned int. I probably used the larger type to ensure there would be plenty of space for very long songs. However when I wrote the rest of the API, I changed to unsigned ints which now clips this upper limit.

Two approaches:

  1. Change ticks to unsigned int. This will lower the max number of ticks which can be stored internally but wouldn't introduce warnings to existing projects.
  2. Change the beat functions to use unsigned long. This would fix the clipping of the max number of beats, but could introduce warnings in people's projects.

UPDATE: Since no one has brought up the issue of not having enough ticks, I'd say 1 would work for now. We can implement 2 if/when that becomes an issue.

danomatika avatar Apr 05 '22 20:04 danomatika