User forums > Using Code::Blocks

Code Sense for unnamed struct/union fields

(1/3) > >>

nightlight:
With stuct/union containing unnamed fields of struct/union type, the CodeSense doesn't display the field names inside these unnamed fields. For example

typedef struct _test {
  int a;
  union {
    int b;
    int c;
    };
  int d;
} TEST;

int main()
{
   TEST xx;
     xx.a=1;
     xx.b=3;   
     ...
}

When "xx." above is typed, CodeSense shows all fields of TEST except for fields 'b' and 'c' which are inside unnamed union (these fields have to have unique names within the structure i.e. one cannot have 'a' or 'd' inside the 'union' above). The VS CodeSense shows all fields, including 'b' and 'c'. It would be much more useful if C::B were to show all fields as well.

{ I am using only the regular release 10.5 of C::B and I don't know whether this was fixed within current nightly buids.}

ollydbg:

--- Quote from: nightlight on October 04, 2010, 02:50:58 am ---With stuct/union containing unnamed fields of struct/union type, the CodeSense doesn't display the field names inside these unnamed fields. For example

typedef struct _test {
  int a;
  union {
    int b;
    int c;
    };
  int d;
} TEST;

int main()
{
   TEST xx;
     xx.a=1;
     xx.b=3;   
     ...
}

When "xx." above is typed, CodeSense shows all fields of TEST except for fields 'b' and 'c' which are inside unnamed union (these fields have to have unique names within the structure i.e. one cannot have 'a' or 'd' inside the 'union' above).

The VS CodeSense shows all fields, including 'b' and 'c'. It would be much more useful if C::B were to show all fields as well.


--- End quote ---

The same in cc_branch.

Did you mean that

--- Code: ---xx.a
xx.b
xx.c
xx.d
--- End code ---

all the above should be auto prompted?

nightlight:
all the above should be auto prompted?

That's how VS does it and it is quite useful. Unlike the named fields, for unnamed fields there is no other way to see those fields in the prompt, short of going back to the declaration in some other file.

BTW, C::B is a great IDE, very well thought out. I had to switch recently to a wider cross platform development (from previously only switching between Windows/VS & MAC/Xcode to include Linux now) and having tried all the IDE tools out there, C::B was the most pleasant and most natural among the alternatives.

ollydbg:

--- Quote from: nightlight on October 04, 2010, 05:17:58 am ---all the above should be auto prompted?

--- End quote ---

This can be fixed.
Currently, there are three items shown when you press the dot

1, a
2, d
3, an UNnamedXXX union.

So, the third entry can be expanded to b,c.

nightlight:
So, the third entry can be expanded to b,c.

Yes, but then the CodeSense inserts as the field name the string UnnamedUnionXXX.b into the code, rather than just b.

Navigation

[0] Message Index

[#] Next page

Go to full version