Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: aXyde on October 13, 2009, 10:09:13 pm

Title: Adding not-included header files to code completition
Post by: aXyde 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.
Title: Re: Adding not-included header files to code completition
Post by: ollydbg 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

Title: Re: Adding not-included header files to code completition
Post by: aXyde 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.
Title: Re: Adding not-included header files to code completition
Post by: blueshake 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.
Title: Re: Adding not-included header files to code completition
Post by: ollydbg 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.