mardi 28 juin 2016

How should I include variable defined with extern in c file

I am having trouble compiling the demonstration code for the STM32F4-Discovery using the arm-none-eabi toolchain. The error is occuring in linking and this is the [first] error I'm receiving.

template/obj/stm32f4xx_it.o: In function `OTG_FS_IRQHandler':
template/src/stm32f4xx_it.c:192: undefined reference to `hpcd'

I've been trying to figure this out on and off for several months so I've created this github repository to track the project. The variable hpcd is defined in template/src/usbd_conf.c. My knowledge of C/C++ is unfortunately full of holes, so I'm hoping someone may help me both narrow down the problem and the suggest the proper way to fix it.

I have two questions.

  1. hpcd is included in the file usbd_conf.c. It is used in many files, but none of these files actually include usbd_conf.c, only usbd_conf.h. The question is, by only including the header, can a file which declares a variable as extern PCD_HandleTypeDef hpcd; use the variable without specifically including the .c file?
  2. Assuming the answer to question 1 is yes, why is it the function OTG_FS_IRQHandler isn't finding hpcd? The chain of includes from stm32f4xx_it is main.h -> usbd_core.h -> usbd_conf.h.

I'm assuming the answer to question 1 is yes because this is the demonstration code I believe was running on the board when I purchased it. I can only assume the poblem is with the way I'm building it. Would anyone be willing to help me troubleshoot this problem? I would be happy to provide more details if relevant or to better structure this question, but I'm trying to avoid posting a full USB stack in my question. Thank you.

Aucun commentaire:

Enregistrer un commentaire