现在的位置: 首页 > 综合 > 正文

Borland C++“浮点格式未链接”错误的官方解释

2013年08月01日 ⁄ 综合 ⁄ 共 9339字 ⁄ 字号 评论关闭
Borland C++“浮点格式未链接”错误的官方解释
by wecan in 技术文档 at 2006年6月6日13:35星期二
 

文章#15204:“浮点格式未链接”消息

 

Article #15204: "Floating point formats not linked" messages.

 

 

 

 

来源:community.borland.com

 

翻译:Wecanhttp://wecan.name

 

 

 

 

文件名TI204C.txt

类型:普通

操作系统:所有

产品:所有Borland C++

 

 

 

问题描述

        此文档将解释程序错误“浮点格式未链接:异常程序中止(FLOATING POINT FORMATS NOT LINKED: ABNORMAL PROGRAM TERMINATION)”产生的原因,并指引你如何解决此问题。除非有特别说明,这个问题及相应的解决方法适用于所有版本的Turbo CTurbo C++Borland C++

 

 

 

什么是浮点格式?

        浮点格式是一个格式化信息的集合,该集合使得一些运行时库函数(runtime library function)可以操作浮点数,比如scanf()atof()

 

 

 

该问题何时会被修复?

         我们并没有计划修复此问题,因为这并不是一个BUG。编译器的原意是在不需要的时候不链接浮点格式,以节约1KB内存。作为交换,程序员必须明确地在那些隐晦地操作浮点数的程序中说明自己的需要。

 

 

 

我该如何去除该错误消息?

        因为有多种可能均可引发该问题,检查下列每个潜在的原因并找到解决该问题的方法。以下列出最普遍的引发该问题的原因:

1、原因:将浮点选项设为None。要操作浮点数,必须将编译器的浮点选项设为Emulation80x87
解决方法:将浮点选项设为Emulation80x87。在集成开发环境(IDE)中,这个选项可能在Options &line; Compiler &line; Advanced Code Generation或者Options &line; Compiler &line; Code Generation &line; More中,这与你所使用的编译器有关。如果使用的是命令行编译器,请使用合适的-f开关。

2、原因:执行TLINK时,库的顺序错误(Cx.LIBEMU.LIB之前列出时将导致此问题。)
解决方法:这个错误通常发生在使用命令行编译器,并将TLINKBCCTCC)分开执行时发生。当执行TLINK时,将库的顺序改变为:
[用户库] [GRAPHICS.LIB] EMU.LIB MATHx.LIB Cx.LIB
(在中括号中的库是可选的。)
注:在《Borland C++ Tools & Utilities Guide》一书的第58页存在一处印刷错误,其中的TLINK命令行中列出的库顺序有误。那个错误的顺序正会导致浮点格式未链接。

3、原因:可能是编译器过度优化了程序,或你的程序操作浮点数时十分有限,并且采用了特殊的方式。在一些隐蔽的场合,编译器会忽略scanf()中使用的浮点数(例如,试图读取结构体(structure)中浮点型数组的一个元素时)。
解决方法:如果你使用的是Borland C++Turbo C++ 3.0以后的版本,请阅读A部分。如果使用的是Borland C++ 2.0Turbo C++ 2.0或任何版本的Turbo C编译器,请阅读B部分。(译者注:此处与原文不同,原文认为任何版本的Turbo C++都必须使用B部分述及的方法,但实际上Turbo C++ 3.0及以后的版本可以使用A部分的方法解决该问题。)
A部分(BC/TC++ 3.0或以后的版本):
        在某一源代码模块中加入:
        extern _floatconvert;
        #pragma extref _floatconvert
        
Borland C++ 3.0READMEHELPME!.DOC文档中,不正确地指出只需在源码中加入
        #pragma extref _floatconvert
        
来解决FPFNL错误。如果你不加入“extern _floatconvert;”这一行,你会得到“未定义符号_floatconvert。(Undefined symbol _floatconvert.)”错误。如果你将两行代码的顺序颠倒,也会得到同样的错误消息。请注意“#pragma”一行的末尾没有分号。如果你加上了分号,将得到“错误的pragma指示语法(Bad pragma directive syntax)”错误。
        Borland C++ 3.1README文档中指出下面的方法:
        extern void _floatconvert();
        #pragma extref _floatconvert
        
也可以解决问题。事实上,_floatconvert是一个变量抑或函数无关紧要,只要链接器可以识别该符号即可。
        BC++ 3.1HELPME!.DOC文档中,已经改正了需要加入的这两行代码的错误。
B部分(BC/TC++ 2.0TC):
        加入源码模块中下面的force_fpf()函数。你不用调用此函数,只需将其包含在某个源码模块中。
        static void force_fpf()
        
            float x, *y; /* Just declares two variables */
            y = &x;      /* Forces linkage of FP formats */
            x = *y;      /* Suppress warning message about x */
        }
        
(译者注:代码中注释的意义为:定义两个变量,强制使用浮点格式链接,使用变量x以防止产生警告信息。)

4、原因:在使用scanf()时忘记在变量表达式前加取址符“&”。例如:
        float foo;
        scanf("%f", foo);
解决方法:修改代码,在需要的地方加上取址符“&”。例如,上面的代码应改为:
        float foo;
        scanf("%f", foo);

5、原因:Turbo C 2.0在使用scanf()时存在一个BUG
解决方法:获取并安装TC2PAT.ARC中的补丁。这个文件可以在DLBBS408-439-9096)中的Languages / C++ / Patches部分下载到。

6、原因:Turbo C 2.01在使用atoof()strtod()时存在一个BUG
解决方法:获取并安装TC21PT.ARC中的补丁。这个文件可以在DLBBS408-439-9096)中的Languages / C++ / Patches部分下载到。

7、原因:试图在IDE中创建一个Phar Lap DOS Extender应用程序。
解决方法:Phar Lap随其DOS Extender提供了一个名为BCC286.EXE的可执行文件。这个程序可以调用Borland的命令行编译器(BCC)和命令行链接器(TLINK)。因为在IDE和命令行下的链接器有所不同,所以你不能在IDE中创建Phar Lap DOS Extender应用程序,让它们正确运行。如果你试图那样做,就可能得到浮点类型未链接的错误消息。解决的方法就是使用命令行工具,BCCTLINK,而不使用IDE
(译者注:DOS Extender是创建DOS保护模式接口(DOS Protected Mode Interface)应用程序的工具,保护模式对应于默认的实模式(Real Mode),它使得DOS应用程序可以使用更多的内存。在实模式下,应用程序最多只能和DOS分享640KB的基本内存。)

 

 

 

关键字FPFNLAPT

免责声明:你有权在随Borland产品提供的实际许可声明的相关约束下使用此技术信息。

参考及引用:(无)

9872 10:39:05 AM

 

最后修改:9991

 

[附:英文文档原文]

community.borland.com

Article #15204: "Floating point formats not linked" messages.

 Technical Information Database

TI204C.txt   "Floating point formats not linked" messages.     
Category   :General
Platform    :All
Product    :Borland C++  ALL   

Description:
  This document explains why you might be getting the error
  FLOATING POINT FORMATS NOT LINKED : ABNORMAL PROGRAM TERMINATION
  and tells you how to resolve it.  The problems and solutions
  below apply to ALL versions of Turbo C, Turbo C++, and Borland
  C++, except where noted.
  What are floating point formats?
  Floating point formats are a collection of formatting information
  used to manipulate floating point numbers in certain runtime
  library functions such as scanf() and atof().
  When will this be fixed?
  There are no current plans to fix this because it is not a bug.
  The intent is to avoid linking the floating point formats (about
  1K of overhead) when they are not required.  The tradeoff of this
  feature is that the programmer must explicitly request that the
  floating point formats to be linked in for some programs which
  manipulate floats in a limited and specific fashion.
  How do I resolve the error message?
  Since you can get the error in a number of different ways, check
  the following list of potential causes to find out how to resolve
  the error.  These are listed in order of most common to least
  common causes.
  1.  CAUSE:  Floating point set to .  Your have your
      floating point option set to None when it should be set to
      either Emulation or 80x87.
      FIX:  Set Floating Point to  or <80x87>.  In the
      Integrated Development Environment (IDE), this is either
      under Options &line; Compiler &line; Advanced Code Generation or
      Options &line; Compiler &line; Code Generation &line; More, depending upon
      which compiler you have.  With the command line compiler, use
      the appropriate -f switch.
  2.  CAUSE:  Misordered libraries when executing TLINK
      (Cx.LIB listed before EMU.LIB will cause the error.)
      FIX:  This possibility usually occurs only when you are using
      the command line compiler and are explicitly calling TLINK
      separately from BCC or TCC.  When executing TLINK, change the
      order of the libraries to
           [user libs] [GRAPHICS.LIB] EMU.LIB MATHx.LIB Cx.LIB
                  (libraries in brackets are optional)
      Note:  There is a misprint in the Borland C++ Tools &
      Utilities Guide on page 58 that displays the wrong order for
      libraries on the TLINK command line.  The ordering shown in
      the manual is exactly what will cause floating point formats
      not linked.
  3.  CAUSE:  Either the compiler is overoptimizing, or the
      floating point formats really do need to be linked in because
      your program manipulates floats in a limited and specific
      fashion.  Under certain obscure conditions, the compiler will
      ignore floating point usage in scanf().  (e.g., trying to
      read into a float variable that is part of an array contained
      in a structure.)
      FIX:  If you have Borland C++ 3.0 or later, read Part A.  If
      you have Borland C++ 2.0 or any Turbo C or Turbo C++
      compiler, read Part B.  This fix is the only fix that will
      solve a "PRINTF : Floating point formats not linked" error
      message occurring with inline assembly.
      Part A (BC++ 3.0 or later):
          Add the following to one source module:
              extern _floatconvert;
              #pragma extref _floatconvert
          The README and HELPME!.DOC files that shipped with
          Borland C++ 3.0 incorrectly say that only
              #pragma extref _floatconvert
          is required in order to resolve the FPFNL error.  If you
          do not include the "extern _floatconvert;" line you will
          get the error "Undefined symbol _floatconvert."  You will
          also get the same undefined symbol if the "extern
          _floatconvert" comes after the #pragma line instead of
          before.  Note that the #pragma line does not have a
          semicolon at the end of the line.  If you put a semicolon
          there, you will get the error "Bad pragma directive
          syntax."
          The README that shipped with Borland C++ 3.1 says that
              extern void _floatconvert();
              #pragma extref _floatconvert
          This should work, as well.  It doesn't really matter
          whether _floatconvert is a variable or a function; it
          only matters that it is some symbol that the linker will
          recognize.
          The HELPME!.DOC for BC++ 3.1 has the correct two lines to
          add.
      Part B (BC++ 2.0 or TC or TC++):
          Add the following force_fpf() function to one source
          module.  It is not necessary to call this function; just
          include it in one of your modules.
          static void force_fpf()
          { 
              float x, *y; /* Just declares two variables */
              y = &x;      /* Forces linkage of FP formats */
              x = *y;      /* Suppress warning message about x */
          }
  4.  CAUSE:  Forgetting to put the address operator & on the scanf
      variable expression.  For example,
          float foo;
          scanf("%f", foo);
      FIX:  Change the code so that the & operator is used where it
      is needed.  For example, the above code should be
          float foo;
          scanf("%f", &foo);
  5.  CAUSE:  A bug in Turbo C 2.0 when using scanf()
      FIX:  Obtain and apply the patches in TC2PAT.ARC.  This file
      can be downloaded from the Languages / C++ / Patches section
      on DLBBS (408-439-9096).
  6.  CAUSE:  A bug in Turbo C 2.01 when using atof() or strtod()
      FIX:  Obtain and apply the patches in TC21PT.ARC.  This file
      can be downloaded from the Languages / C++ / Patches section
      on DLBBS (408-439-9096).
  7.  CAUSE:  You are trying to create a Phar Lap DOS Extender
      application with the Integrated Development Environment
      (IDE).
      FIX:  Phar Lap includes an executable called BCC286.EXE with
      their DOS Extender.  This program calls Borland's command-
      line compiler (BCC) and command-line linker (TLINK).  Since
      the linker in the IDE is different than the linker at the
      command line, you cannot create Phar Lap DOS Extender
      applications in the IDE and expect them to run properly.  If
      you try to do so, you might get a floating point formats not
      linked error message.  The fix is to use the command line
      tools, BCC and TLINK, instead of the IDE.
  Keywords:  FPFNL , APT
  DISCLAIMER: You have the right to use this technical information
  subject to the terms of the No-Nonsense License Statement that
  you received with the Borland product to which this information
  pertains.

Reference:

7/2/98 10:39:05 AM
 
Last Modified: 01-SEP-99 

Permanant URI 永久地址 http://wecan.name/diary/i......cleid=a_20060606_133520
Trackback URI 引用地址 http://wecan.name/diary/tb.php?tb_id=1149572120
请不要吝惜您的评论,每一条评论,都是我在漫漫长夜前行的力量...

 

抱歉!评论已关闭.