Author Topic: Scope of tags and defines  (Read 2556 times)

Offline MarkVonShief

  • Single posting newcomer
  • *
  • Posts: 3
Scope of tags and defines
« on: April 14, 2015, 05:50:11 pm »
I have been using C::B for a couple years or more and have one peeve that keeps me thinking that I need to go back to SlickEdit

My code (C) consists of a few hundred source and header files, and some pieces of source code are either included or not with compile-time defines.  These defines are sometimes in quite a different part of the tree than where they are used, but all the files are in the project and I can see the defines set in the symbol table and the project compiles and links.  The source code in the editor doesn't seem to be able to see them, however, and a simple search for symbol declaration comes up empty unless I load the file with the declaration into the editor.  The editor also colors these sections as if the declaration is never made, and that's whether it has opened the file with the declaration or not.

for instance, one of the first lines of sourcecode would contain:

#if FEATURE__THISISAFEATURE

and the Preprocessor symbols tab shows:

# FEATURE__THISISAFEATURE:1

and the sourcecode following the #if will still be gray'ed out, as if the symbol was never defined.

I haven't been able to find any setting to get the correct scope and I'm really surprised that I haven't been able to find a solution to this searching the forum and elsewhere online because my project is really not all that complex that other folks wouldn't have run into this.

again - this is just an aggravation

Thanks for any thoughts - MvS

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Scope of tags and defines
« Reply #1 on: April 14, 2015, 07:19:02 pm »
i think (and i'm not sure) that the coloring the defines comes from wxScintilla and this doesn't know anything about the other files and the compiler options. So if you define and use something in two different files Scintilla isn't able to detect it. Maybe it will get fixed in some version...

greetings

Offline MarkVonShief

  • Single posting newcomer
  • *
  • Posts: 3
Re: Scope of tags and defines
« Reply #2 on: April 14, 2015, 09:19:57 pm »
Makes sense, I wish there were a way around it

if I put the line:

#define FEATURE__THISISAFEATURE 1

in front of the #if statement then of course all is well (except with the compiler).  so that's the local scope needed.  The funny thing is that c::b knows all about the preprocessor defines and sorts them alphabetically and everything.

I'm hoping that maybe somebody might have an idea around it

thanks for the reply - M

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Scope of tags and defines
« Reply #3 on: April 14, 2015, 09:26:36 pm »
The problem is that this is really just a simple scintilla feature. You have to provide the defines to scintilla to work correctly. However we cannot provide all defines collected, this is meaningless. All we do is to provide some major and project specific defines. Maybe it can be improved somehow though... Patches are welcome.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ