Skip to main content
MCrew.1
Associate III
November 5, 2020
Question

Debugging in STM32CubeIDE

Hello,

I am working on a project where I have created several of my own files (.h and .cpp) but I am having issues with undefined reference to certain functions. I cannot solve this issue while having the files separated, but I was wondering if it is possible to generate and view the files combined together in assembly code? The functions are accessible in the main.c file, but not in my own files.

Thanks,

MC

This topic has been closed for replies.

4 replies

TDK
November 5, 2020

You need to put the function definitions in a header file and then #include that header in the source files you wish to use it in. This is a basic C concept.

main.h:
 
void my_function();
 
 
main.c:
 
#include "main.h"
 
void my_function() {
 // stuff...
}
 
 
 
other_source_file.c:
 
#include "main.h"
 
void other_function() {
 my_function();
}

"If you feel a post has answered your question, please click ""Accept as Solution""."
MCrew.1
MCrew.1Author
Associate III
November 6, 2020

I know this concept and I have done this already, however I am trying to debug the undefined reference error.

TDK
November 6, 2020

An "undefined reference error" suggests you haven't done this correctly.

"If you feel a post has answered your question, please click ""Accept as Solution""."