armembeddedcortex-mkeilarmcc

assigning a variable using binary format - 0B causing error in ARM Keil uVision


I am workin on a project with TM4C123GH6PM micro-controller using keil uvision version 4.7. When I assign a value to a variable in binary format like the following:

unsigned char tmp = 0b11000011;

and then I build the project, the following error appears:

expected a ";"

When I change the format to hex -using 0X- or Decimal, the error disappears.

doesn't the compiler in Keil uVision support the binary format?


Solution

  • ANSI C doesn't specify a syntax for binary literals. Keil compilers follow the ANSI C standard, and their manual usually record any deviations or extensions.

    A previous discussion on this can be found here Why doesn't C have binary literals?