Author Topic: Adding not-included header files to code completition  (Read 2950 times)

Offline aXyde

  • Single posting newcomer
  • *
  • Posts: 3
Adding not-included header files to code completition
« on: October 13, 2009, 10:09:13 pm »
Hi,

is there a way to add stuff from header files that are not really added inside the code to the code completition feature (the thing when u push strg + space)?

Example: if you use the glut framework you only want to do "#include <GL/glut.h>" and not "#include <GL/gl.h> #include <GL/glu.h>" but I still want to have those GL-functions inside my code completition.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5341
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Adding not-included header files to code completition
« Reply #1 on: October 14, 2009, 03:06:06 am »
Hi,

is there a way to add stuff from header files that are not really added inside the code to the code completition feature (the thing when u push strg + space)?

Example: if you use the glut framework you only want to do "#include <GL/glut.h>" and not "#include <GL/gl.h> #include <GL/glu.h>" but I still want to have those GL-functions inside my code completition.

Hi, I'm not sure if GL/glut.h is internally include gl.h and glu.h, if it is true, then all the headers will be automatically parsed by CodeCompletion. That's because CC will do the include file expansion. :D

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline aXyde

  • Single posting newcomer
  • *
  • Posts: 3
Re: Adding not-included header files to code completition
« Reply #2 on: October 14, 2009, 12:31:57 pm »
Hi, I'm not sure if GL/glut.h is internally include gl.h and glu.h, if it is true, then all the headers will be automatically parsed by CodeCompletion. That's because CC will do the include file expansion. :D

Well i'm using some framework similar to glut, its called glfw but I chose glut for my example because its more popular. And all my GL code runs flawlessly without including gl or glu. So i guess C::B does not to this "include file expansion", is there a way to turn it on/off? Or maybe it just doesn't parse includes that are inside a preprocessor condition.

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: Adding not-included header files to code completition
« Reply #3 on: October 14, 2009, 12:38:39 pm »
Quote
Or maybe it just doesn't parse includes that are inside a preprocessor condition.

#if
#else
is not supported.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5341
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Adding not-included header files to code completition
« Reply #4 on: October 14, 2009, 03:16:50 pm »
#if
#else
is not supported.

From the source code of parserthrerad.cpp

Code
void ParserThread::HandlePreprocessorBlocks(const wxString& preproc)
{
    if (preproc.StartsWith(ParserConsts::kw_if)) // #if, #ifdef, #ifndef
    {
        wxString token = preproc;
        ++m_PreprocessorIfCount;

        token = m_Tokenizer.GetToken();
        if (token.IsSameAs(_T("0")))
        {
            // TODO: handle special case "#if 0"
            TRACE(_T("HandlePreprocessorBlocks() : Special case \"#if 0\" not skipped."));
        }
        m_Tokenizer.SkipToEOL();
    }
    else if (preproc==ParserConsts::kw_else || preproc==ParserConsts::kw_elif) // #else, #elif
    {
        TRACE(_T("HandlePreprocessorBlocks() : Saving nesting level: %d"), m_Tokenizer.GetNestingLevel());
        m_Tokenizer.SaveNestingLevel();
        wxString token = preproc;
        while (!token.IsEmpty() && token != ParserConsts::kw_endif)
            token = m_Tokenizer.GetToken();
        --m_PreprocessorIfCount;
#if PARSERTHREAD_DEBUG_OUTPUT
        int l = m_Tokenizer.GetNestingLevel();
#endif
        m_Tokenizer.RestoreNestingLevel();
        TRACE(_T("HandlePreprocessorBlocks() : Restoring nesting level: %d (was %d)"), m_Tokenizer.GetNestingLevel(), l);
    }
    else if (preproc==ParserConsts::kw_endif) // #endif
        --m_PreprocessorIfCount;
}

only #if is treated, and #else is omitted.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.