cancel
Showing results for 
Search instead for 
Did you mean: 

I have an error of "multiple definition of `ProcessChar' I have the function ProcessChar() in two source files. There are no header files or prototypes that should make these functions global.

Mike xx
Associate III

This is a project created with STM32CubeMX and then coding in the STM32CubeIDE environment.

The error is in the linking process, but wondering why the linker should believe this function is defined twice by default. I had reason to believe these should be local to their own translation units/source files and so the linker treated these are entirely different functions.

I am aware that functions in different source files with the same names is undesirable, but I would prefer to get top the bottom of this rather than simple rename the functions.

1 ACCEPTED SOLUTION

Accepted Solutions

Unless defined as static, body functions will be visible in the global name-space.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

4 REPLIES 4

Unless defined as static, body functions will be visible in the global name-space.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Mike xx
Associate III

Many thanks for your quick reply, I thought functions would be local static by default. On some further research I can see this that functions are indeed global.

Many thanks again.

@Community member​ "On some further research I can see this that functions are indeed global"

Indeed: this is standard C - nothing specific to CubeIDE.

>  I thought functions would be local static by default.

This is a difference between C and C++.

In C, functions are 'extern' unless declared static.