Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: hanshuckebein on January 08, 2021, 04:35:51 pm

Title: C: CB's knowledge on #defines is unreliable
Post by: hanshuckebein 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.
Title: Re: C: CB's knowledge on #defines is unreliable
Post by: stahta01 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.

Title: Re: C: CB's knowledge on #defines is unreliable
Post by: hanshuckebein on January 09, 2021, 12:48:27 am
I'm using the linux version.
Title: Re: C: CB's knowledge on #defines is unreliable
Post by: hanshuckebein 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
Title: Re: C: CB's knowledge on #defines is unreliable
Post by: oBFusCATed 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. :)
Title: Re: C: CB's knowledge on #defines is unreliable
Post by: hanshuckebein 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.
Title: Re: C: CB's knowledge on #defines is unreliable
Post by: oBFusCATed on January 14, 2021, 06:54:50 pm
There is already such option. Settings -> Editor -> General -> Somewhere...
Title: Re: C: CB's knowledge on #defines is unreliable
Post by: BlueHazzard on January 15, 2021, 12:19:41 am
Settings->Editor settings->General settings->C/C++ Editor settings->Interpret #if,#else.....