danomatika / ofxMidi

(maintained) Midi addon for openFrameworks
Other
262 stars 72 forks source link

explicit conversion : Just to get rid of warnings #84

Closed dimitre closed 10 months ago

dimitre commented 2 years ago

not sure if its the best way

danomatika commented 2 years ago

What is the warning?

dimitre commented 2 years ago

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

dimitre commented 2 years ago

it can be supressed by

pragma GCC diagnostic ignored "-Wshorten-64-to-32"

danomatika commented 2 years ago

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 commented 10 months ago

Thanks