PortMidi / portmidi

portmidi is a cross-platform MIDI input/output library
Other
118 stars 33 forks source link

fix warning from XCode #45

Closed sl1200mk2 closed 1 year ago

sl1200mk2 commented 1 year ago

declaration shadows a variable in the global scope [-Wshadow]

rbdannenberg commented 1 year ago

@begin(soapbox)These false-negative warnings really annoy me. Local scopes were invented to make code more modular and to allow shadowing of globals. It's a feature.@end(soapbox) But OK, given that xcode makes mistakes, we can minimize the damage by eliminating the source of xcode's confusion. But I really don't want a name like lisIAC -- I get it -- "local" isIAC -- but I'd prefer to change the name of the isIAC global, e.g. to isIACdevice. But why is it a global? It would be more proper for it to be part of PmInternal, or since PmInternal is "generic", the data really belongs in PmInternal->api_info, and sure enough api_info is a core_midi_info_type, which has an isIACdevice field. Did I forget it was there and added the global array isIAC[]? I think the global isIAC can be completely removed, but I'll have to look at the history to see how it got there, and maybe I'm missing something.

rbdannenberg commented 1 year ago

OK, it turns out isIAC is needed because the core_midi_info_type structure doesn't exist until you open a device (I think, at least I saw that isIAC[i] gets copied to ->isIACdevice. So I changed some other isIAC locals to iac_flag. Also fixed some other compiler warnings and suggested removal of unused variables and code.