Question about a C code (why the do-while loop?)

Status
Not open for further replies.

alsig

Junior Member level 1
Joined
Jan 17, 2005
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
160
C question

Hi,

I stumbled upon this code

Code:
#if !defined(USE_INTERRUPTS)
#define Init()    
#else                    
#define Init()                      do { InitTMR2();\
                                    } while (0)

and I don’t understand why the do-while loop is used. Why not just skip it?

By the way I’m not sure this is the right forum, sorry

Alsig
 

Re: C question

Sure, you can skip the while no need for that here
 

C question

It may be leftover debugging code. The programmer can make the loop spin forever by simply changing the 0 to 1.
 

Re: C question

echo47 said:
It may be leftover debugging code. The programmer can make the loop spin forever by simply changing the 0 to 1.

What could be the reason to make timer initialization (InitTMR2) forever? ;-)

I think this is just phantom stubs code. Just delete this "do-while".
Also, I think the following article will be helpful for everyone. I read it with pleasure.
https://www.nedbatchelder.com/text/deleting-code.html
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…