Author Topic: C Preprocessing  (Read 5130 times)


  • Community Member
  • Posts: 10
  • Hero Points: 0
C Preprocessing
« on: October 11, 2006, 10:59:26 am »
" C Preprocessing

Displays the C/C++ Preprocessing dialog box. Use this dialog to modify preprocessing so that our tagging can better analyze your code."

What exactly is "better"? What tagging problems are solved when I will the dialog with #defines?

Basically, what I'm asking is what is this dialog for and how and when should I use it?



  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: C Preprocessing
« Reply #1 on: October 11, 2006, 01:18:46 pm »
Slick tagging takes care about #ifdef's (and friends) in source files.
E.g. an #if 0 ... #endif prevents the enclosed block from being tagged by Slick and of course from getting compiled ...



  • Community Member
  • Posts: 42
  • Hero Points: 5
Re: C Preprocessing
« Reply #2 on: October 11, 2006, 01:24:44 pm »
Constructs such as these confuse the slick parser, causing FooClass not to be tagged.

I use C Preprocessing to define away mDLLIMPORTEXPORT macro, which fixes tagging.


  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4739
  • Hero Points: 383
Re: C Preprocessing
« Reply #3 on: October 11, 2006, 02:43:24 pm »
Use C Preprocessing only when you notice a symbol lookup problem.  If you notice that symbols are not being found, there's a good chance it is due to preprocessing.  Well written C++ code rarely needs this.  Older C and C++ code use defines quite a bit.  We already have preprocessing defined for some very commonly used C++ libraries like QT, boost (added recently), MFC, GNU C++ run-times, Visual C++ run-times, and more.  Even our own code for SlickEdit needs a small number of defines.

Here's the one thing we needed to define preprocessing for in the SlickEdit source:

The code below is some parts from one of our header files.

#ifdef SLICK_C
   #define INIT_TO(e) =e
   #define COMMON
   #define INIT_TO(e)
   #define COMMON  extern
   COMMON int gJawsMode;
   COMMON unsigned char gapp_has_focus INIT_TO(1);
#undef  COMMON
#undef  INIT_TO

The above code avoids duplicate definitions of global scope variables.  We define COMMON to nothing and define INIT_TO(e) to nothing.  I know the INIT_TO define is a bit problem but COMMON might get ignored by the parser any way.  There's really no way around this in C++ other than to write your code in Java or C# instead :-)


  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2707
  • Hero Points: 413
Re: C Preprocessing
« Reply #4 on: October 12, 2006, 03:12:14 pm »
Disclaimer:  This code is provided for as a preprocessing example only.  Please do not do this in your own code.