Fatal error when including USB Device Library

Hi, I started playing with DaisyExamples/seed/USB_CDC example and my new Seed board and wanted to go into the code and see how the USB handler works. At some point, I wanted to try some stuff out without libDaisy abstractions, similar to how people end up using AVR directly instead of Arduino abstractions (as is my case but I’m not yet familiar with STM32).

Here’s what I got:

  • Successfully installed the toolchain on macOS.
  • Cloned the repo and built the libraries without issues.
  • Navigated to the example folder and make; make program the firmware to the board successfully.
  • Started looking around and learning how the CDC driver works, my IntelliSense in VS Code wasn’t picking up the functions from usbd_cdc_if.h, so I included it without thinking and got an error:
../../libDaisy/src/usbd/usbd_cdc_if.h:32:10: fatal error: usbd_cdc.h: No such file or directory
   32 | #include "usbd_cdc.h"
      |          ^~~~~~~~~~~~                                                 

I assumed that the header file is included already anyway since the usb_handle is using it but I don’t understand the source of this error. You can reproduce it by slapping #include "usbd_cdc.h" anywhere in USB_CDC.cpp and the thing just won’t compile. usbd_cdc.o is present in the library build folder after building the lib. Am I missing something obvious?

Thank you.

usbd_cdc_if.h isn’t intended to be #include’d in an application, it’s just used in building the library

1 Like

Could you please explain to me the mechanism? I’m curious how a piece of code becomes “unavailable” to me once the library that uses it is built. I’m able to #include header files from Core but not Class? Regardless of what’s the intended use.

The Makefile for USB_CDC, and the Makefile IT includes :
include $(SYSTEM_FILES_DIR)/Makefile

don’t expose the location of ‘usbd_cdc.h’

From this :
“I assumed that the header file is included already anyway since the usb_handle is using it”

it would appear that you’re under the misapprehension that the contents of header files include’d during the build of a library are available during compilation of a program using
that library.
My guess is that you come to C and C++ from the Arduino world.