bob.sacamento
bob.sacamento

Reputation: 6651

What is this "loop (..) { .. }" syntax construct? (Not in K&R)

C isn't my first language, but I've written a good bit of it. I am examining a code and I have come across a construct I have never see before:

loop(i,nlevels)
{
  /* do stuff based on "i"  */
}

There is no do, for, or while. "i" is not acted on inside the loop. I assume this means loop over "i" sequentially from 0 to nlevels (or maybe nlevels-1), but I don't know. I can't find this in K&R. I can't find it on the internet. Can someone enlighten me? Thanks.

Upvotes: 9

Views: 474

Answers (3)

Veger
Veger

Reputation: 37915

This macro is probably defined somewhere:

#define loop(index, steps) for(int index = 0; index <= steps; index++)

Or one that is looking very similar to it

Upvotes: 14

Stephanie Miller
Stephanie Miller

Reputation: 134

Is loop a macro #defined somewhere? It seems an easy enough macro that someone may want to have done so.

Upvotes: 4

Pubby
Pubby

Reputation: 53067

loop is most certainly a macro someone defined as it's not part of the C language.

Search for a #define loop.

Upvotes: 17

Related Questions