0

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?

A.Mak
  • 13
  • 3

3 Answers3

1

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?

Anakin
  • 111
  • 6
  • thanks for your clarification. Seems ARMCC compiler doesn't use an extension to support the binary format. – A.Mak Feb 19 '21 at 18:21
1

The Keil Arm v5 (ARMCC) compiler does not support binary literals. But the Keil Arm V6 (ARMCLANG) compiler does support binary literals. The Arm v6 compiler option is available with Keil MDK v5.12 and later. You may need to port some of your code to switch compiler versions (Migration Guide).

kkrambo
  • 6,253
  • 1
  • 16
  • 30
0

Open the "Options for target" --> switch to "C/C++" tab --> add --gnu in "Misc Controls" textbox.

Codes like int a = 0b101010; compile with no error.

I am using MDK 5.18 and ARMCC V5.06 update1 (build 61)

Alleria
  • 119
  • 1
  • 9