Skip to content

Commit fb36be8

Browse files
authored
fix(usb_midi): Add macro guards
1 parent 059a037 commit fb36be8

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

cores/esp32/Arduino.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ size_t getArduinoLoopTaskStackSize(void);
222222
return sz; \
223223
}
224224

225+
#if CONFIG_TINYUSB_MIDI_ENABLE
226+
// Forward declaration of USBMIDI class for the SET_USB_MIDI_DEVICE_NAME macro
227+
#include "USB/USBMIDI.h"
225228
#define SET_USB_MIDI_DEVICE_NAME(name) \
226229
namespace { \
227230
static const char* _usb_midi_default_name = name; \
@@ -231,7 +234,17 @@ size_t getArduinoLoopTaskStackSize(void);
231234
} \
232235
} _usb_midi_name_setter; \
233236
}
234-
237+
#else
238+
#define SET_USB_MIDI_DEVICE_NAME(name) \
239+
namespace { \
240+
static struct _USBMIDINameSetter { \
241+
_USBMIDINameSetter() { \
242+
log_e("USB MIDI is not enabled. Enable it in menuconfig under Component Config -> TinyUSB -> CDC Enable"); \
243+
} \
244+
} _usb_midi_name_setter; \
245+
}
246+
#endif
247+
235248
bool shouldPrintChipDebugReport(void);
236249
#define ENABLE_CHIP_DEBUG_REPORT \
237250
bool shouldPrintChipDebugReport(void) { \

0 commit comments

Comments
 (0)