Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
johnDoe32138yWell ya... ";" Typically terminates a statement so it's looping but not accessing the curly brackets.
-
Looks like someone experienced one too many nights hunting for a missing ; and decided to overcompensate.
-
johnDoe32138y@DrEmann with C language I know you can do a while loop spin lock like this. The classic semaphore example; while(flag); causes a thread to wait in place until another thread/activity sets flag to false. So I think it would work with a for loop
-
@Lisanna this happened to me too. But I fail to see why this is semantically the same as do nothing once? Would declaring the flag volatile force the compiler to not optimize it away?
-
johnDoe32138y@Lisanna never said it was a good example, just used it as an example of putting a semicolon right after some sort of loop
-
johnDoe32138y@Lisanna Classic as in it's generally how the concept of a semaphore is taught ;3 most sites/textbooks will often use a simple while loop lock to show the idea behind the waiting
Related Rants
for(i = 0; i < n; i++);//<-- this one
{
//Do stuff
}
One day struggling why this for loop in C just iterates once, found out that ";" was leaving the for body empty, and the "Do Stuff" ended beign out of the for.
undefined
c