Author Topic: C Preprocessing  (Read 4991 times)

suevian

  • 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?

Thanx.

hs2

  • Senior Community Member
  • Posts: 2736
  • 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 ...

HS2

sdayts

  • 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.
class mDLLIMPORTEXPORT FooClass
{
};

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

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4652
  • Hero Points: 373
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
#else
   #define INIT_TO(e)
   #define COMMON  extern
#endif
   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 :-)




Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2631
  • Hero Points: 405
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.