We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello all, My project with 3 files as following ,the MAIN is in sys.c,all 3 files are compiled well each other. File a: including sys.c and common.h File b: including rtk.c and rtk.h File c: including blt.c and blt.h rtk.h: ... extern uchar code rtk_Cmd[20]={...}; extern struct Time {uchar Sec;...}; extern struct Date {...}; extern struct Time sGps; ... rtk.c: #include <rtk.h> ... syc.c: #include <common.h> #include <rtk.h> #include <blt.h> .... void main() { ... Func1(sGps.Sec); Func2(rtk_Cmd); ... } when build all files, the error L104:mutiple public defintion (rtk_cmd) Warning L1: unresolved external symbol(sGps). Give me your hands ,thanks a lot!
"You have DECLARED GpsInfo in rtk.h Then, you include rtk.h in both rtk.c and sys.c files - therefore you have declared it twice (in both of files) - resulting in 'Multiple public definition' error." Not quite: He has defined GpsInfo in rtk.h - resulting in 'Multiple public definition' error. The definition must be in exactly one source file; there can be as many extern declarations as you like!