3

I came across some C code which has 'unsigned' declaring a variable all by itself, like this:

unsigned crc = 0;

I think this is very strange because I'd expect an explicit variable type here. I'm surprised that there aren't any compiler warnings or errors (MDK-Lite 5.12).

So, is this valid, and what kind of variable does it produce?

beeflobill
  • 317
  • 1
  • 10

1 Answers1

11

From the C specification, section 6.7.2:

— unsigned, or unsigned int

Meaning that unsigned, when not specified the type, shall default to unsigned int. So writing unsigned a is the same as unsigned int a.

Bruno Ferreira
  • 1,621
  • 12
  • 19