[comp.sys.ibm.pc.misc] Borland C++ and Floating Point Math

sharif@lamar.colostate.edu (Thomas Abdallah) (04/13/91)

Okay,  It's about time to begin pulling hair out !

I've been fighting with Borland's C++ v2.0 trying to get it to handle
floating point numbers.  The manual specifically states that :

	"The default Borland C++ code generation option is emulation
	     ^^^^^^^
	 (the -f command-line compiler option).  This option is for
	 programs that may or may not have floating point, and for
	 machines that nay or may not have an 80x87 math coprocessor."

	-Borland C++ Programmers Guide, p.220

When I use the BUILD option I can see the stupid thing compile my program
and then actually read the EMU.LIB file during its link phase.  Now when
I try to go back and execute the bloody thing I get a big fat error telling
me that the floating point library has not been linked.  What gives ?????

Has anyone been this thoroughly frustrated with the damn thing?  One thing
that REALLY bothers me about Borland's products is that they don't use
environment variables.  At least with MSC I knew why things weren't linked
properly; I usually had been messing with my CONFIG.SYS file the night
before and screwed up my LIB or INCLUDE variables.  With this thing I have
no clue!  (btw.  I checked the little TLINK.CFG file and it is going to the
right place .. this is a bogus way of handling what should be env-vars!)

                                                           vvvvvvv
Anyway,  I've about had it for tonight.  Any help would be GREATLY appreciated.
                                                           ^^^^^^^

----------------------------------------------------
Thomas-Sharif Abdallah
Starving CIS Grad Student -- Colorado State Univ.
sharif@lamar.colostate.edu
----------------------------------------------------

sharif@lamar.colostate.edu (Thomas Abdallah) (04/16/91)

Thanks to all those who responded to my post about this floating-point
problem.
                                    __       ________
                                   /..\  ___/ Ouch ! \
                                   \--/     \________/
                     _________  _ --||--
                    /         \/.\/ ||
                    \_________/\_/\ /\
                    / | | | | \    /  \

	... I've been bitten by the famous linker bug !

-----------------------------------------------------
Thomas-Sharif Abdallah
Starving CIS Grad Student -- Colorado State Univ.
sharif@lamar.colostate.edu
-----------------------------------------------------

mgphl@msa3b.UUCP (Michael Phillips) (04/16/91)

sharif@lamar.colostate.edu (Thomas Abdallah) writes:

>Okay,  It's about time to begin pulling hair out !

>I've been fighting with Borland's C++ v2.0 trying to get it to handle
>floating point numbers.  The manual specifically states that :

>	"The default Borland C++ code generation option is emulation
>	     ^^^^^^^
>	 (the -f command-line compiler option).  This option is for
>	 programs that may or may not have floating point, and for
>	 machines that nay or may not have an 80x87 math coprocessor."

>	-Borland C++ Programmers Guide, p.220

>When I use the BUILD option I can see the stupid thing compile my program
               ????????     
>and then actually read the EMU.LIB file during its link phase.  Now when
>I try to go back and [rest deleted]

You say "build" ? I assume then that you are compiling from the IDE,
please check "OPTIONS" --> "Code generation" --> "more" and insure
that the "project file" (or default, if no prj is active) specifies
"floating point emulation" and not "none".   I believe that the TLINK.CFG
is NOT used by the IDE.

Hope this helps.

******************************************************************************
| Michael G. Phillips          | "Only two things are infinite, the universe | 
| Dun & Bradstreet Software    | and human stupidity, and I'm not sure about |
| ..!gatech!nanovx!msa3b!mgphl | the former"   --   Albert Einstein          |
******************************************************************************

eclarke@ibmpa.awdpa.ibm.com (Eric S. Clarke) (04/18/91)

In article <1602@msa3b.UUCP>, mgphl@msa3b.UUCP (Michael Phillips) writes:
|> sharif@lamar.colostate.edu (Thomas Abdallah) writes:
|> 
|> >Okay,  It's about time to begin pulling hair out !
|> 
|> >I've been fighting with Borland's C++ v2.0 trying to get it to handle
|> >floating point numbers.  The manual specifically states that :
|> 
|> >	"The default Borland C++ code generation option is emulation
|> >	     ^^^^^^^
|> >	 (the -f command-line compiler option).  This option is for
|> >	 programs that may or may not have floating point, and for
|> >	 machines that nay or may not have an 80x87 math coprocessor."
|> 
|> >	-Borland C++ Programmers Guide, p.220
|> 
|> >When I use the BUILD option I can see the stupid thing compile my program
|>                ????????     
|> >and then actually read the EMU.LIB file during its link phase.  Now when
|> >I try to go back and [rest deleted]
|> 
|> You say "build" ? I assume then that you are compiling from the IDE,
|> please check "OPTIONS" --> "Code generation" --> "more" and insure
|> that the "project file" (or default, if no prj is active) specifies
|> "floating point emulation" and not "none".   I believe that the TLINK.CFG
|> is NOT used by the IDE.

I read the original post with interest because I was having some floating 
point problems myself.  I am not sure if the problem you are having is the same
as the one that I had, but here is the solution to mine.

I was reading some floating point numbers from a file with fscanf.  The 
program compiled fine, I too could see that the EMU.LIB file was being
linked.  But, when I ran the program the first time it hit the fscanf with
the %f format, it would abort.  The message stated that "floating point
formats not liked."

After waiting on hold for some length of time, a very helpful person at
Borland explained the problem.  The compiler is too smart for its own good.
Those are my words, not those of the person at Borland.  It seems that 
TC++ and BC++ decide if floating point routines need to be linked into the
package based on some magic cookies.

My program only read the floating point numbers and then wrote them back to
a file with out actually manipulating them.  So the compiler decided that
I didn't need any floating point routines.  To solve this just add to lines to
the program.

    float foo, *junk;

    junk = &foo;

The program now runs just fine.  The person at borland said he would add my
name to the list of people that have requested 1) Documentation about this
feature and 2) A method of neatly overriding the feature.

-- 

Eric S. Clarke                     INTERNET:  eclarke@ibmpa.awdpa.ibm.com 
1510 Page Mill Road                    UUCP:  uunet!ibmsupt!eclarke
Palo Alto, CA 94304                IBM VNET:  ECLARKE at AUSVMQ
415-855-4458  T/L: 465-4458            

jja@wsl.ie (John Allen on wsl) (04/18/91)

In article <14197@ccncsu.ColoState.EDU> sharif@lamar.colostate.edu (Thomas Abdallah) writes:
>Okay,  It's about time to begin pulling hair out !
>
>I've been fighting with Borland's C++ v2.0 trying to get it to handle
>floating point numbers.  The manual specifically states that :
> etc, etc....
>no clue!  (btw.  I checked the little TLINK.CFG file and it is going to the
>right place .. this is a bogus way of handling what should be env-vars!)
>

Actually environment variables are a bogus way of handling configuration files.
This problem is an FAQ and has been answered so many times it is becoming 
ridiculous.
-- 
People that don't know want to know from the people that do know and if the 
poeple that do know don't tell the people that don't know then the people
that don't know still won't know.
				   "Don't quote me on any issue whatsoever."