home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / os2 / programm / 8012 < prev    next >
Encoding:
Text File  |  1993-01-25  |  2.0 KB  |  58 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!well!shiva
  3. From: shiva@well.sf.ca.us (Kenneth Porter)
  4. Subject: Re: Why I will choose Borland
  5. Message-ID: <C1FIzA.JD0@well.sf.ca.us>
  6. Sender: news@well.sf.ca.us
  7. Organization: Whole Earth 'Lectronic Link
  8. References: <C0tEEw.Fyt@well.sf.ca.us> <1993Jan14.070243.2427@ccsvax.sfasu.edu> <1993Jan14.161935.5498@gandalf.UMCS.Maine.EDU> <8438@lib.tmc.edu>
  9. Date: Mon, 25 Jan 1993 21:42:46 GMT
  10. Lines: 46
  11.  
  12.  
  13. In article <8438@lib.tmc.edu> jmaynard@oac.hsc.uth.tmc.edu (Jay Maynard) writes:
  14. >In article <1993Jan14.161935.5498@gandalf.UMCS.Maine.EDU> jurlwin@gandalf.UMCS.Maine.EDU (Jeff Urlwin) writes:
  15. >>How about the warning about relational expression is always true?
  16. >>while (1)
  17. >>{
  18. >>do something
  19. >>if something
  20. >>  break;
  21. >>do some more...
  22. >>}
  23. >
  24. >It proably wants you to rewrite that as
  25. >flag=0;
  26. >while(!flag) {
  27. >        foo;
  28. >        if (bar)
  29. >                flag=1;
  30. >        baz;
  31. >}
  32.  
  33. I've successfully used "for (;;)" to mean loop forever. In fact, I've seen
  34. system include files (I think on the Amiga) that have
  35.  
  36. #define FOREVER for (;;)
  37.  
  38. A couple of people also mentioned the trick of using a void cast to get
  39. rid of the parameter-not-used warning, so I've now got a macro for it:
  40.  
  41. #define ParameterNotUsed(param) ((void)(param))
  42.  
  43. This seems to be portable (Borland C++ likes it, too, but MSC6
  44. complains that "statement has no effect" :-( ), so I'll discontinue
  45. using the associated pragma.
  46.  
  47. The empty for loop *can* be re-written as a while loop, as that
  48. construct is usually used to search for a value in a list or array; I
  49. like the for construct because it groups the initialization with the
  50. test. I flag the empty for body by always putting the trailing
  51. semicolon on a separate line.
  52.  
  53. Has anyone come up with an elegant way to eliminate the
  54. "fall-through" warning if a case in a switch statement continues to
  55. the next case? I've seen lint constructs like /*FALLTHROUGH*/, so I
  56. put such a comment in when that's what I intend. This should occur a lot
  57. in PM and Windows code where switch statements make up 90% of the code.
  58.