Closed supsm closed 2 months ago
I'm not sure I understand why/how are you trying to compile this example as C++.(or what you mean by it).
I'm not sure I understand why/how are you trying to compile this example as C++
I initially saved the file as .cpp to modify it in a more familiar language (not realizing isr_usbctrl is a special function). I suspect other developers may also attempt to unsuccessfully incorporate isr_usbctrl into C++ code.
Is there any update on this pr? I have already made the requested changes.
Seems fine to me
The USB dev_lowlevel example silently fails in C++ because
isr_usbctrl
is name-mangled and therefore not registered as an interrupt handler. This PR addsextern "C"
to use C linkage for this function and allow compiling as C++.It is certainly not the prettiest, but it is necessary for correct behavior (with C++ linkage, none of the host's packets are responded to and the device is useless). The alternative to this is to manually specify
irq_set_exclusive_handler
, probably withinusb_device_init
. The pico-sdk advertises itself as C/C++, so C++ compatibility should be taken into consideration in its examples.