How to enable linking floating point library in TurboC?

人走茶凉 提交于 2019-11-26 17:18:44

问题


I'm newbie in C language... Just want to ask how to enable linking floating point library in TurboC?


回答1:


From the comp.os.msdos.programmer FAQ:

"Floating point formats not linked" is a Borland run-time error (Borland C or C++, Turbo C or C++). Borland's compilers try to be smart and not link in the floating- point (f-p) library unless you need it. Alas, they all get the decision wrong. One common case is where you don't call any f-p functions, but you have %f or other f-p formats in scanf() or printf() calls. The cure is to call an f-p function, or at least force one to be present in the link.

To do that, define this function somewhere in a source file but don't call it:

static void forcefloat(float *p)   
{
     float f = *p;
     forcefloat(&f);    
}

It doesn't have to be in the module with the main program, as long as it's in a module that will be included in the link.



来源:https://stackoverflow.com/questions/6223453/how-to-enable-linking-floating-point-library-in-turboc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!