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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...