Welcome, Guest. Please login or register.

Author Topic: Super newbie C questions  (Read 5422 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Sidewinder

  • Full Member
  • ***
  • Join Date: Mar 2002
  • Posts: 241
    • Show all replies
    • http://www.liquido2.com
Re: Super newbie C questions
« on: June 30, 2008, 01:32:16 AM »
Quote
Line 132 states:
window_signal = 1L << MyWindow->UserPort->mp_SigBit;


This is right out of the RKM.  I personally think it's ugly, but does anyone have another method that isn't equally ugly?

Quote
So it is like I suspected, UserPort->mp_SigBit is literal.

And he uses the AND bit operator on the bitmask of the signal because if he OR'ed it he would get TRUE also if he wasn't listening for it, but it was set in the value he was testing on (I just realised this).


I'm glad it's making more sense now.  Was the text confusing in some way?  Is there another way I could explain in the tutorial that would be more clear?

Quote
But what can the Wait function return when you haven't given it an OR'ed list of signals you're waiting on, but just one single signal.


Like Piru said, in this case the AND is redundant because Wait() only returns one signal.  But if you added another window, then your input signal mask to Wait() would have two bits set and you'd need to AND the result of Wait() against each window's signal mask to determine which window signaled.

Quote
I think I get it now. Now, I'd like to find a book or net articles on good C coding practices on the Amiga. :)


Well, there is a lot of old/bad example code out there.  For this tutorial I attempt to use an ANSI C style while following the RKMs as much as possible.  Not that the RKMs are the definitive guide to Amiga coding style either...but I digress.
Sidewinder