Category : C Source Code
Archive   : BCPPTECH.ZIP
Filename : TI645.ASC

 
Output of file : TI645.ASC contained in archive : BCPPTECH.ZIP







PRODUCT : C++ NUMBER : 645
VERSION : All
OS : DOS
DATE : February 25, 1992 PAGE : 1/2

TITLE : Floating Point Formats Not Linked




What is the floating point emulator and when is it used?

The floating point emulator is used to manipulate floating point
numbers in runtime library functions like scanf() and atof().

What causes the error?

When parsing your source file, if the compiler encounters a
reference to the address of a float, it sets a flag to have the
linker link in the floating point emulator. There are some cases
in which the reference to the float is a bit obscure and the
compiler does not detect the need for the emulator. The most
common is using scanf() with a pointer to a struct containing a
float.

For example:

struct foo
{
float fvar;
};

void main(void)
{
struct foo s1, *s2 = &s1;
scanf("%f", &s1->fvar);
}

These situations usually occur during the initial stages of
program development. Normally, once the program is fully
developed, the emulator will be used in such a fashion that the
compiler can accurately determine when to link in the emulator.

How can I force the formats to be linked?

To force linking of the floating point emulator to be linked into
an application, just include the following function in your
program:


















PRODUCT : C++ NUMBER : 645
VERSION : All
OS : DOS
DATE : February 25, 1992 PAGE : 2/2

TITLE : Floating Point Formats Not Linked




void LinkFloat (void)
{
float a=0, *b=&a; /* cause emulator to be linked */
a=*b; /* suppress warning var not used */
}

You do not need to call this function, just include it anywhere
in your program. Once your project has reached its full size,
you will most likely be able to remove it from the program.

When will this be changed?

There are no current plans to change the inner workings of the
compiler because the intent is to avoid linking the floating
point emulator (about 1k of overhead) when it is not required.

Special Cases

An exception to this rule occurs with Turbo C version 2.01 when
using the atof() function. This is a mistake and is fixed in a
patch file called tc21pt.arc, which is available on CompuServe in
forum BPROGB, LIB 5. It is also available for download on the
Borland BBS which can be reached at 408.439.9096.




























  3 Responses to “Category : C Source Code
Archive   : BCPPTECH.ZIP
Filename : TI645.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/