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

Status
Not open for further replies.

#### alsig

##### Junior Member level 1
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

#### jshroff

Re: C question

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

#### echo47

C question

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

#### Ace-X

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.