Hi,
I'm using uVision 5 to develop a firmware, however I can't get the linker to find one of my functions. When building, I get this error:
Error: L6218E: Undefined symbol three()
I have 3 files, main.c, Test.h, Test.c
main.c :
#include "Test.h"
int main() { return three(); }
Test.h :
#ifndef TEST_H #define TEST_H
int three();
#endif
Test.c
int three() { return 3; }
All those files are at the root of my project, I know they get compiled as if I introduce a syntax error in them, compiler reports an error. Also looking at the map file produced, I see that three() was removed:
Removing test.o(i.three), (4 bytes).
For testing purposes, I had --no_remove to linker command line, map file now contains:
0x0002ba76 0x00000004 Code RO 1 i.three test.o
So obviously, the linker is well aware of my function, and will or won't remove it depending on flags.
Regardless, it reports:
.\build\uvision5\test.axf: Error: L6218E: Undefined symbol three() (referred from main.o). Not enough information to list image symbols.
If I move the content of Test.h/.c to main.c, no problem, so the code is correct.
I suspect a linker configuration or a project configuration issue, but I'm really stuck !
Thanks for your help!
Sorry, yes, I tend to do a lot more C++. I however had checked that possibility without success (and my original issue is with another function that actually takes parameters, this code is my attempt to write minimal code to reproduce my issue). Thanks!
Subject closed, terrible mistake from me. It was actually main.cpp, not main.c. So the function had to be declared as described here: http://www.keil.com/support/docs/3223.htm
Apologies and thanks for your kind help!