PDA

View Full Version : Struct Parsing, multiple name typedef failing



Syndacate
11th July 2011, 20:28
Typically QT Creator has an amazing C/C++ parser, but I ran into something used pretty frequently that it's choking on.

That's a struct declared like this:

typedef struct _a_struct
{
int member a;
int member b;
} a_struct, *a_struct_ptr;

That is legal in C and I see it pretty often, this creates two typedefs, a typedef of the struct named "a_struct", and a type of "a_struct_ptr" which is an "a_struct" pointer.

When used like this:
a_struct a;
a.<ctrl+space> it autocompletes fine

When used like this:
a_struct_ptr ptr;
ptr-><ctrl+space> it doesn't autocomplete at all.

Not sure why, I hit "F2" on a_struct_ptr and it recognizes where it was type-def'ed, so it should know what it is. Anybody have a fix for this or know what the problem is?

Added after 1 31 minutes:

Just for clarification, this only happens on type-def'ing multiple names when one is a pointer.

Example:
typedef struct _a
{
int a;
} A, B;

Works fine, as it should.

On the other hand:
typedef struct _a
{
int a;
} A, *B;

Does not, A will auto-complete, B will auto-complete the TYPE, but will NOT autocomplete the members, ie.
B a_variable;
a_variable-><ctrl+space>

Doesn't work, but:
A *a_variable;
a_variable-><ctrl+space>
OR
A a_variable;
a_variable.<ctrl+space>

Both work perfectly fine.

stampede
12th July 2011, 07:47
Same here (Qt Creator 2.2). You may want to check if this bug is reported on Qt issue tracker (http://bugreports.qt.nokia.com/secure/Dashboard.jspa) (and maybe report it if it's not).