Re: Alternatives to #define?
From: Alf P. Steinbach (alfps_at_start.no)
Date: 07/04/04
- Next message: David Harmon: "Re: Wireless Networking"
- Previous message: JKop: "Re: Purchasing The Standard"
- In reply to: Rolf Magnus: "Re: Alternatives to #define?"
- Next in thread: Rob Williscroft: "Re: Alternatives to #define?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 04 Jul 2004 18:27:58 GMT
* Rolf Magnus:
> Alf P. Steinbach wrote:
>
> > * Rolf Magnus:
> >> Alf P. Steinbach wrote:
> >>
> >> > * Rolf Magnus:
> >> >>
> >> >> #define DO_STUFF do { doThis(); doThat(); } while(false)
> >> >
> >> > Unfortunately that may cause a warning with too "helpful" compilers
> >> > such as Visual C++.
> >> >
> >> > Try instead
> >> >
> >> > #define DO_STUFF for(;;){ doThis; doThat(); break; }
> >>
> >> Hmm, what would you gain with that for loop?
> >
> > See above.
>
> No, I mean what you gain compared to just:
>
> #define DO_STUFF() { doThis(); doThat(); }
>
Uhm, see my reply to Rob Williscroft. I was wrong. And the extreme
irony is that I've always used do-while for such things precisely
because a simple block won't do wrt. semicolon syntax, and done my best
to teach that technique to others (since you can read Norwegian as well
as C++ code I can offer an example of such teaching, namely the XASSERT
macro in <url: http://home.no.net/dubjai/03/index.html#cpputil>,
presumably some Googling on newsgroup posting would give more examples).
-- A: Because it messes up the order in which people normally read text. Q: Why is it such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail?
- Next message: David Harmon: "Re: Wireless Networking"
- Previous message: JKop: "Re: Purchasing The Standard"
- In reply to: Rolf Magnus: "Re: Alternatives to #define?"
- Next in thread: Rob Williscroft: "Re: Alternatives to #define?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|