Re: My idea of fully-portable C code
- From: Chris H <chris@xxxxxxxxxxxx>
- Date: Wed, 14 May 2008 07:08:41 +0100
In message <bf1f13dd-5bb1-4da7-b339-dbfc46944cca@xxxxxxxxxxxxxxxxxxxxxxxxxxx>, Tomás Ó hÉilidhe <toe@xxxxxxxxxxx> writes
On May 13, 7:59 pm, Hans-Bernhard Bröker <HBBroe...@xxxxxxxxxxx>
wrote:
> #define TOTAL_BITS_NEEDED (QUANTITY_CHUNKS * BITS_PER_CHUNK)
Bad macro. Parentheses missing around QUANTITY_CHUNKS and
BITS_PER_CHUNK leave the code vulnerable to funny definitions of those
constants (e.g. #define BITS_PER_CHUNK 2+3) The same problem occurs
repeatedly later on.
You're confusing things. A macro is a self-contained, self-sufficient
entity. If I have a macro called QUANTITY_CHUNKS, then it should be
able to be used on its own without parentheses. If it needs
parentheses, then it is ill-formed.
Now you are running counter to most standards and guides for portability and safety.
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
.
- Follow-Ups:
- Re: My idea of fully-portable C code
- From: Thad Smith
- Re: My idea of fully-portable C code
- References:
- My idea of fully-portable C code
- From: Tomás Ó hÉilidhe
- Re: My idea of fully-portable C code
- From: Hans-Bernhard Bröker
- Re: My idea of fully-portable C code
- From: Tomás Ó hÉilidhe
- My idea of fully-portable C code
- Prev by Date: hai denger website
- Next by Date: Re: Best way to get 2.5 volts from somewhere? (Vcc = 5 volts)
- Previous by thread: Re: My idea of fully-portable C code
- Next by thread: Re: My idea of fully-portable C code
- Index(es):
Relevant Pages
|