Author Topic: C: CB's knowledge on #defines is unreliable  (Read 5760 times)

Offline hanshuckebein

  • Multiple posting newcomer
  • *
  • Posts: 36
C: CB's knowledge on #defines is unreliable
« on: January 08, 2021, 04:35:51 pm »
Very often, but not always, #defines in header files do not result in ungraying corresponding conditional blocks in the editor.

The same for -D command line options for avr-gcc. Interestingly the command line symbol F_CPU is known to the editor.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7678
    • My Best Post
Re: C: CB's knowledge on #defines is unreliable
« Reply #1 on: January 08, 2021, 05:26:46 pm »
Very often, but not always, #defines in header files do not result in ungraying corresponding conditional blocks in the editor.

The same for -D command line options for avr-gcc. Interestingly the command line symbol F_CPU is known to the editor.

I have noticed the first; but, never saw the second happen. Defines in the CB Compiler project settings have always worked for me.

Tim S.

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline hanshuckebein

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: C: CB's knowledge on #defines is unreliable
« Reply #2 on: January 09, 2021, 12:48:27 am »
I'm using the linux version.

Offline hanshuckebein

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: C: CB's knowledge on #defines is unreliable
« Reply #3 on: January 14, 2021, 04:37:15 pm »
Here is the proof, that -D compiler options and predefined symbols also do not influence rendering of inactive text in the editor – see the attachment.

I'm using C:B 20.03 on Linux Mint 19.2

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: C: CB's knowledge on #defines is unreliable
« Reply #4 on: January 14, 2021, 04:50:53 pm »
Patches welcome.
Just keep in mind that the macro parser in Scintilla is primitive and doesn't support complex cases, so in theory this feature would never work reliably.

p.s. I've not investigated this deeply, so I would be happy to be proven wrong. :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline hanshuckebein

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: C: CB's knowledge on #defines is unreliable
« Reply #5 on: January 14, 2021, 05:37:29 pm »
Quote
Just keep in mind that the macro parser in Scintilla is primitive and doesn't support complex cases, so in theory this feature would never work reliably.

Then the best would be a switch to disable that feature, since unreliable highlighting is very confusing in files with a lot of conditional blocks, like in the headers of avr-lib.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: C: CB's knowledge on #defines is unreliable
« Reply #6 on: January 14, 2021, 06:54:50 pm »
There is already such option. Settings -> Editor -> General -> Somewhere...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: C: CB's knowledge on #defines is unreliable
« Reply #7 on: January 15, 2021, 12:19:41 am »
Settings->Editor settings->General settings->C/C++ Editor settings->Interpret #if,#else.....