Author Topic: C Preprocessing  (Read 7115 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: 2761
  • Hero Points: 292
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: 6862
  • Hero Points: 528
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

  • Senior Community Member
  • Posts: 3960
  • Hero Points: 517
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.