1

I am working on a project with the TM4C123GH6PM microcontroller using Keil 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 μVision support the binary format?

Peter Mortensen
31.3k22 gold badges110 silver badges134 bronze badges
asked Feb 19, 2021 at 16:50
1
  • 1
    What did the Keil documentation say? Commented Feb 19, 2021 at 18:01

3 Answers 3

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?

answered Feb 19, 2021 at 16:59
Sign up to request clarification or add additional context in comments.

1 Comment

thanks for your clarification. Seems ARMCC compiler doesn't use an extension to support the binary format.
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).

answered Feb 19, 2021 at 22:22

Comments

1

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

Code like int a = 0b101010; compiles without any error.

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

Peter Mortensen
31.3k22 gold badges110 silver badges134 bronze badges
answered Apr 21, 2021 at 2:49

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.