Re: OSS sound

Luke Deller <[email protected]>
Newsgroups gmane.comp.emulators.winex.devel
Message-ID <[email protected]>
Rob Crittenden wrote:

>>>It also seems strange to go thru the trouble of a while loop that will always
>>>be false...
>>>
>>
>>It's a standard C idiom to make macros look like functions. Once can 
>>write CLEAR_OMR(parm); in the code (note semicolon)
> 
> 
> Yes, I understand how macros work. My question is why have a do/while loop that
> will always exit at the first test? Why not write the macros as:
> 
> ...
> #define CLEAR_OMR(omr) { int x = 0; read((omr)->msg_pipe[0], &x, sizeof(x)); }
> #define RESET_OMR(omr) { } 
> ...

Your suggestion would break code such as:
     if (...)
         CLEAR_OMR(omr);
     else
         ...;

The compiler would produce a syntax error at the "else" keyword.

See why?  It might help to look at the expansion of the above code 
(reindented and commented for clarity):

     if (...)
     {
         int x = 0;
         read((omr)->msg_pipe[0], &x, sizeof(x));
     } /* if statement ends here */

     ; /* empty statement */

     else /* error: else occurs without a matching if */
         ...;

Regards,
Luke.



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.