C99 Mode – Whatever that is…

So, I’ve never dabbled in C until now while using it with AVR microcontrollers – and while trying to complie a simple for loop:

  for (uint8_t bit = 0x80; bit; bit >>= 1) {
    ...
  }

I got this error:

error: 'for' loop initial declaration used outside C99 mode

and to fix it I would move my decloration of the varabile outside of the loop. This seemed stupid to me so a quick Google search turned up this

Back in the old days, when dinosaurs roamed the earth and programmers used punch cards, you were not allowed to declare variables anywhere except at the very beginning of a block.

Solution was to add -std=c99 to the Makefile. My new AVR Makefile now looks like this..