home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
progc
/
c_all592.arj
/
TI645.ASC
< prev
next >
Wrap
Text File
|
1992-02-25
|
3KB
|
133 lines
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.