From 5b74eed7da7af522dd384280bff8d54bc0c9622d Mon Sep 17 00:00:00 2001 From: Toyomasa Watarai Date: Mon, 20 Apr 2015 14:34:47 +0900 Subject: [PATCH] [USBMIDI] Fix compile error * Member variables in USBMIDIMessage and USBMIDI class wrongly initialized in class declaration * Add member initialization in constructor --- libraries/USBDevice/USBMIDI/MIDIMessage.h | 6 +++--- libraries/USBDevice/USBMIDI/USBMIDI.cpp | 4 +++- libraries/USBDevice/USBMIDI/USBMIDI.h | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/USBDevice/USBMIDI/MIDIMessage.h b/libraries/USBDevice/USBMIDI/MIDIMessage.h index d1a2bc58e7..9cfcf13635 100644 --- a/libraries/USBDevice/USBMIDI/MIDIMessage.h +++ b/libraries/USBDevice/USBMIDI/MIDIMessage.h @@ -44,9 +44,9 @@ /** A MIDI message container */ class MIDIMessage { public: - MIDIMessage() {} + MIDIMessage() : length(4) {} - MIDIMessage(uint8_t *buf) { + MIDIMessage(uint8_t *buf) : length(4) { for (int i = 0; i < 4; i++) data[i] = buf[i]; } @@ -270,7 +270,7 @@ public: } uint8_t data[MAX_MIDI_MESSAGE_SIZE+1]; - uint8_t length=4; + uint8_t length; }; #endif diff --git a/libraries/USBDevice/USBMIDI/USBMIDI.cpp b/libraries/USBDevice/USBMIDI/USBMIDI.cpp index a46f9ae77d..084574a790 100644 --- a/libraries/USBDevice/USBMIDI/USBMIDI.cpp +++ b/libraries/USBDevice/USBMIDI/USBMIDI.cpp @@ -20,7 +20,9 @@ #include "USBMIDI.h" -USBMIDI::USBMIDI(uint16_t vendor_id, uint16_t product_id, uint16_t product_release): USBDevice(vendor_id, product_id, product_release) { +USBMIDI::USBMIDI(uint16_t vendor_id, uint16_t product_id, uint16_t product_release) + : USBDevice(vendor_id, product_id, product_release), cur_data(0), data_end(true) +{ midi_evt = NULL; USBDevice::connect(); } diff --git a/libraries/USBDevice/USBMIDI/USBMIDI.h b/libraries/USBDevice/USBMIDI/USBMIDI.h index a7818dd8ce..cc5be5b7d8 100644 --- a/libraries/USBDevice/USBMIDI/USBMIDI.h +++ b/libraries/USBDevice/USBMIDI/USBMIDI.h @@ -103,8 +103,8 @@ protected: private: uint8_t data[MAX_MIDI_MESSAGE_SIZE+1]; - uint8_t cur_data=0; - bool data_end = true; + uint8_t cur_data; + bool data_end; void (*midi_evt)(MIDIMessage); };