using sprintf causes link to fail

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

using sprintf causes link to fail

跳至解决方案
2,161 次查看
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.
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,072 次查看
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 项奖励
回复
1 回复
1,073 次查看
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 项奖励
回复