Jump to content
Sign in to follow this  
Steve_DeGroof

Boolean Functions

Recommended Posts

How do I create a function that returns a boolean? What I've tried so far is creating a function that returns a short:

 

  short isTxBufferReady();

 

However, if I try to use this in a conditional:

 

  while (!isTxBufferReady())

 

...I get an "unexpected unary" error. The only solution I came with was to use:

 

  while (isTxBufferReady()==0)

 

I can live with that but I wonder if I've missed a more obvious solution.

Share this post


Link to post
Share on other sites

OK, I just tried a few things and cam up with some interesting results:

 

  while (txBufferIsReady()) //this compiles

  while (!(txBufferIsReady())) //so does this

  while (txBufferIsReady()==0) //and this

  while (!txBufferIsReady()) //this one gives "unexpected unar operation"

 

This would seem to indicate that the compiler is attempting to evaluate the "!" operator before evaluating the txBufferIsReady function. I was under the impression that functions counted as membership operators and, therefore, had higher precedence than unary operators.

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...
Sign in to follow this  

×
×
  • Create New...