When declaring things in a header file that must be visible/linkable from both C and C++, the standard technique is:
#ifdef __cplusplus
extern "C" {
#endif
/* declarations go here */
#ifdef __cplusplus
}
#endif
One occasionally sees an alternate form:
#if defined(__cplusplus)
extern "C" {
#endif
/* declarations go here */
#if defined(__cplusplus)
}
#endif
In the USB 5.0 stack, files fsl_usb_ehci_hal.h and fsl_usb_khci_hal.h contain the first (opening) block but never the second (closing) block. File fsl_usb_khci_hal.h contains it in two places. If those header files are ever imported by a C++ module, the compiler will be very unhappy.
Admittedly, these two headers will probably not see C++ usage any time soon.
Hi John,
Thanks for your report! I have passed it to our USB stack team, and this would be fixed in the next release.
Best Regards,
Kan