Skip to main content
eschl
Associate
September 30, 2019
Question

Question about redefinition

  • September 30, 2019
  • 3 replies
  • 1589 views

Hi all,

just a short question:

Why does the compiler say that the page is redefined?

#define ADDR_FLASH_PAGE_148 ((uint32_t)0x0804A000)
#define ADDR_FLASH_PAGE_149 ((uint32_t)0x0804A800)

Same page but with small letters and that's ok for the compiler.

#define ADDR_FLASH_PAGE_148 ((uint32_t)0x0804a000)
#define ADDR_FLASH_PAGE_149 ((uint32_t)0x0804a800)

I've got hundreds of warnings within my defines beacuse of that.

Can anyone explain that to me?

Regards,

Enrico

This topic has been closed for replies.

3 replies

waclawek.jan
Super User
September 30, 2019

It's not the compiler who says that, but the preprocessor.

And it's because the preprocessor is [mostly] a textual processor, it does not understand what's in the macro; so all it can do is to compare the text. And, as C is generally case sensitive, "((uint32_t)0x0804A000)" and "((uint32_t)0x0804a000)" are not the same.

JW

Ozone
Principal
September 30, 2019

Check surrounding # if / # ifdef preprocessor directives.

The multiple sections are probably for different variants, and the compiler is supposed to see only one, by chosing the proper variant define.

Another area where cube creates kind of a hefty mess.

eschl
eschlAuthor
Associate
September 30, 2019

​Okay, thank you.

I thought the prepropressor had an issue while comparing

#define ADDR_FLASH_PAGE_148 ((uint32_t)0x0804A000)
#define ADDR_FLASH_PAGE_149 ((uint32_t)0x0804A800) 

and stopping the comparison after the capital letter. Because the two pages have different addresses and I thought the type of letters doesn't matter for the comparison.

Tesla DeLorean
Guru
September 30, 2019

It would need to be identical to be the same.

Perhaps it indicates files/lines for the conflicts? You could also find-in-files or grep, and then eliminate the conflicts.​

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..