Jump to content
TomF

Cannot Cast From Test_Bit

Recommended Posts

This compiles:

 

bool bNewState = true;

 

bool bCurrentOutputState = test_bit(LAT_DIGITAL_OUT, PIN_DIGITAL_OUT);

 

if( bNewState != bCurrentOutputState )

{

}

 

This compiles:

 

 

bool bNewState = true;

 

if( bNewState != (test_bit(LAT_DIGITAL_OUT, PIN_DIGITAL_OUT) ? true:false) )

{

}

 

 

This doesn't:

 

 

bool bNewState = true;

 

if( bNewState != (bool) test_bit(LAT_DIGITAL_OUT, PIN_DIGITAL_OUT) )

{

}

 

 

Any idea what is wrong with the 3rd code segment?

Edited by TomF

Share this post


Link to post
Share on other sites

Hi Tom,

 

Casting to bool is not supported in SB.

 

The boolean lvalue I suppose implies casting to bool.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. 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.

Loading...

×
×
  • Create New...