Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

syntax

loops

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.

like image 591
bob.sacamento Avatar asked Jan 22 '13 19:01

bob.sacamento


2 Answers

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

Search for a #define loop.

like image 59
Pubby Avatar answered Sep 23 '22 18:09

Pubby


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

like image 27
Veger Avatar answered Sep 22 '22 18:09

Veger