Skip to main content
Mike xx
Associate III
February 6, 2022
Solved

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.

  • February 6, 2022
  • 2 replies
  • 1953 views

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.

This topic has been closed for replies.
Best answer by Tesla DeLorean

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

2 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
February 6, 2022

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

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Mike xx
Mike xxAuthor
Associate III
February 6, 2022

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.

Andrew Neil
Super User
February 7, 2022

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

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

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.