Author Topic: Problems with code completion?  (Read 3400 times)

Offline manciuleas

  • Multiple posting newcomer
  • *
  • Posts: 20
Problems with code completion?
« on: September 10, 2007, 02:27:48 pm »
Hi,

I'm using codeblocks rev 4450, but I encountered the problem in earlier versions as well.
I created a project with 2 files: a.h and a.cpp with the following contents:

a.h:

#ifndef A_H_INCLUDED
#define A_H_INCLUDED

struct str_1
{
    int a;
    char b;
};

class A
{
public:
    A() {};
    void InitStruct(int, char);
    void InitInt(int);

protected:
    struct str_1 m_Struct1;
    int m_Int;
};

#endif // A_H_INCLUDED

a.cpp:

#include "a.h"

void A::InitStruct(int i, char c)
{
    m_Struct1.a = i;
    m_Struct1.b = c;
}

void A::InitInt(int i)
{
    m_Int = i;
}

The problem is that "Find declaration of: m_Struct1" does not work, i.e. it's reported as not found, whereas the same thing works for m_Int. But if I do the following changes in a.h then "Find declaration of: m_Struct1" works:

struct str_1
{
    int a;
    char b;
};

becomes:
typedef struct str_1
{
    int a;
    char b;
} AStruct;

and in class A:

struct str_1 m_Struct1; is replaced with AStruct m_Struct1;

Code completion does not work at all for variables of type structure, i.e. after typing "." after m_Struct1 no pop-up menu with the structure members appear.

Regards


Offline manciuleas

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Problems with code completion?
« Reply #1 on: September 11, 2007, 10:14:20 am »
Bump.
No one interested?

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Problems with code completion?
« Reply #2 on: September 11, 2007, 11:15:26 am »
It should just work if you just replaced "struct str_1 m_Struct1;" with "str_1 m_Struct1;".
The former is the old C way which is not fully supported by our parser.

If you 're writing C++, try sticking to its "ways". It will only benefit you :) (and also us, by hiding some CC bugs like this one ;)).
Seriously, this is a known bug (I believe there is a bug report on it too) but don't expect a fix any time soon.
Be patient!
This bug will be fixed soon...

Offline manciuleas

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Problems with code completion?
« Reply #3 on: September 11, 2007, 11:28:58 am »
Thanks mandrav for your answer.
Unfortunately the project I'm working at is quite big so I'll have to live with that.
But in the future I'll do like you suggested.

Regards

Offline incorrect user

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: Problems with code completion?
« Reply #4 on: September 13, 2007, 01:27:51 pm »
Mandravelos is the best! Thanx a lot for such cool and rapidly developing IDE!
Waiting for release 2... ;)
Take quality as a rule!