Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top