Re: A92: What the heck is wrong with this?!


[Prev][Next][Index][Thread]

Re: A92: What the heck is wrong with this?!




The answer is simple :  TIGCC does not supposrt float yet. But your case is
quite interesting. Here are some explanations :

> int key;
> 
> key = 3.8 * 2.0;            // this line works fine


This line work fine because the expression (3.8 * 2.0) will always be equal
to 7.6, so gcc automatically replace this line by the following :
  key = 7;
and so there are no floating-point operations here.


> key2 = 3.8 * key;       // this line always gives the errors, because it is 

Here, the expression (3.8 * key) depend of the key's current value. So the
expression can't be computed at the compilation time, it has to be done
during execution. And since TIGCC doesn't support floating point it can't be
compiled.


> ANOTHER example:
> _main()
> {
> int a;
> a = 0;
> a *= 3.8;   // Why is this giving an error!!!!!!!
> }
> 


Did you try to use some optimisation flags ? Try to compil like this :
  gcc -O2 file.c 

If the -O2 flag is not used, gcc won't notice that 'a' will have a constant
value. So this will still give an error. But I don't know if tigcc.exe use
this flag.


-- 

    Jean-Baptiste CANAZZI
    bloozed@multimania.com
    http://www.multimania.com/bloozed


References: