how to solve this stray issue

75 views Asked by At

I'm using atollic to program stm32, but atollic does not accept hex numbers when I write in a form 0xXXXXXXXX.

#include "stm32f4xx.h"
void gpioab_config(void) {
    RCC->AHB1ENR=0x00000000; //ahb1 channel reset
    RCC->AHB1ENR=0x00000003; //AHB1 ENABLED FOR PORT A AND PORT B
    GPIOA->MODER =0x0C000000; //A PORT INPUT
    GPIOA->OTYPER= 0x00000000; //input port push pull
    GPIOA->OSPEEDR=0x0000003C; //pa1 and pa2 speed set to very high
    GPIOA->PUPDR=0x00000028; // pa1 and pa2 has been set to pull down

    GPIOB->MODER = 0x‭55000000‬; // b ports pb12 pb13 pb14 and pb15 pins are selected as output
    GPIOB->OTYPER = 0x00000000; //OUTPUT PORTS PUSH PULL
    GPIOB->OSPEEDR = 0x‭FF000000‬; //pb12 pb13 pb14 and pb15 speed set to very high
    GPIOB->PUPDR = 0x00000000; //pb12 pb13 pb14 and pb15 are no pull-Up_down

}


int main(void)
{


  while (1)
  {

  }
}

The error that atollic is showing is this:

image

How can I solve this?

atollic does not recognize hex numbers like 0xff0000, 0x550000, ...

1

There are 1 answers

2
DevSolar On

The two offending lines contain Unicode control characters U+202D (left-to-right override) after the 0x and U+202C (pop directional formatting) in front of the ; (most likely from a copy-paste of those values from a website).

'vim' screenshot

This makes the two hex literals... not hex literals at all, which the compiler complains about. Those control characters have no business being in C++ source.

Make sure to set up your editor so that it will make you aware of such characters in some way, or use a source checker that will highlight non-standard characters. Personally, I have a little tool that will warn me if my source contains tabs (using spaces for indentation), non-ASCII-7 characters, or trailing spaces.