Re: conditional operator again
- From: "junky_fellow@xxxxxxxxxxx" <junky_fellow@xxxxxxxxxxx>
- Date: 8 Jun 2006 00:46:33 -0700
Markus Moll wrote:
a) You lose some type-safety.
b) With macros, you should _always_ enclose the parameters in parenthesis:
#define func(flag, ptr) (( (flag) == 1 || (flag) == 2) ...
c) Your parameters may be evaluated more than once, which might lead to
problems (especially as you call your macro "func"):
ptr2 = func(++flag, ptr); // undefined
d) It's terrible to read.
All in all, don't do it.
Thanks for your suggestions. Just to clarify, nowhere in my code func()
will be
called as
ptr = func(++flag, ptr). In fact, flag is not a integer variable. It is
always called as
ptr = func(HASH_DEF_VALUE, ptr). where HASH_DEF_VALUE may be 1, 2 or
3.
And, also *ptr will never be NULL.
.
- References:
- conditional operator again
- From: junky_fellow@xxxxxxxxxxx
- Re: conditional operator again
- From: Markus Moll
- conditional operator again
- Prev by Date: Re: Any references on pattern matching?
- Next by Date: Re: Strange Question
- Previous by thread: Re: conditional operator again
- Next by thread: Re: conditional operator again
- Index(es):
Relevant Pages
|
|