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