Jump to content

Floats in C Functions


Recommended Posts

I am trying to use  C function to do some calculations, but the compiler is choking on the following line:

 if (  IF_GT(1, RemainingCableLength, CurrentCablePosition) ) {}

If I replace this line with a simple "if(1)", the function compiles just fine.  I'm using the macros for all float manipulation and like I said it compiles without this line above.   The error messages from the compiler is cryptic at best and not very helpful.  Can anyone give me a hint as to what might be wrong?

 

 

Link to comment
Share on other sites

The RLO that is being sent to IF_GT is being set to the value of the result of the IF_GT, so if you just pass 1, then it will try to set the return value into a const.

The IF_GT also doesn't return a boolean.

You should rather do:

 

   int rlo = 1;
   IF_GT(rlo, RemainingCableLength, CurrentCablePosition);
   if (rlo == 1)
   {
   }

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.