IAR Error[Li006] 'duplicate definitions' - but not on CubeIDE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-03-14 12:59 AM - last edited on 2025-03-14 3:45 AM by Andrew Neil
I'm trying to move my project from CubeIDE to IAR 9.20.4
For some reason I'm gettin Linker Error[Li006] duplicate definitions.
With CubeIDE I'm able to compile and debug/download with no issue.
I know the error is due to the fact I'm having variables on the .h files included in various .c files that are not set as external.
The question is why CubeIDE ignore this issue and the IAR do not?
Solved! Go to Solution.
- Labels:
-
STM32CubeIDE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-04-28 6:35 AM
The use of something like:
int x;
within a header file is, according to the C Standard, a tentative definition.
Any tentative definition for which an actual definition does not exist within a translation unit becomes a definition at the end of the translation unit when it is compiled. This means that the above use within a header file does result in multiple definitions of x if the header file is included in multiple translation units.
It is therefore perfectly reasonable for IAR to issue a diagnostic, but the standard does not require this behaviour (it is a link-time issue). GCC will do the same with the default -fno-common, but not with -fcommon.
As @Andrew Neil says above, it really is much better to use extern.

- « Previous
-
- 1
- 2
- Next »