using sprintf causes link to fail

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

using sprintf causes link to fail

Jump to solution
1,575 Views
dougm
Contributor I
char szTest[16];
sprintf(szTest,"Test\r\n");

Link Error : L1822: Symbol _STORE_FAR_16 in file C:\Program Files\Metrowerks\CodeWarrior CW12_V3.0\lib\HC12c\lib\ansib.lib is undefined
Link Error : L1822: Symbol _STORE_FAR_32 in file C:\Program Files\Metrowerks\CodeWarrior CW12_V3.0\lib\HC12c\lib\ansib.lib is undefined
Link Error : Link failed

The entire project was set up using the wizard. I tried changing from ansib.lib to ansis.lib with the same result. I also tried defining _STORE_FAR_16 using a -D_ANSI_FAR_16 as a linker arg but the linker doesn't recognize the -D_ANSI_FAR_16 and barfs with an invalid command line. What do I need to do in the project to be able to use the ansi library files like sprintf, etc.
Labels (1)
Tags (1)
0 Kudos
1 Solution
486 Views
CompilerGuru
NXP Employee
NXP Employee
Those functions are defined in datapage.c, usually this file is added by the wizard as well. So you just need to add this file to your project, it is located in lib\hc12c\src.

Also note that HC12 V4.5's sprintf does not use _STORE_FAR_16 in its default configuration (I think there is a libdefs.h option). Not sure, but can be that previous versions of sprintf did reference it.

Daniel

View solution in original post

0 Kudos
1 Reply
487 Views
CompilerGuru
NXP Employee
NXP Employee
Those functions are defined in datapage.c, usually this file is added by the wizard as well. So you just need to add this file to your project, it is located in lib\hc12c\src.

Also note that HC12 V4.5's sprintf does not use _STORE_FAR_16 in its default configuration (I think there is a libdefs.h option). Not sure, but can be that previous versions of sprintf did reference it.

Daniel
0 Kudos