User forums > Using Code::Blocks

Don't understand the "Multiples matches" of "Find declaration"

(1/2) > >>

Teybeo:
I always declare my structures like this:

--- Code: ---typedef struct Thing {
    int var;
} Thing;

--- End code ---

When I want to go to its declaration, I right-click and choose "Find declaration of: 'Thing' ".

But then an intermediate window pop telling me there are multiples matches:

--- Code: ---class Thing {...}
--- End code ---
and

--- Code: ---typedef Thing Thing
--- End code ---


* 1. Why does it print that 'class' word which don't exist in C ?
* 2. Why the second line is "typedef Thing Thing" ? Didn't I wrote a "typedef struct Thing Thing ?"
 
And finally, those multiple matches are obviously redundant in my case and that popping window bothers me.
Is there something that can be made (both in my coding or in CodeBlocks) to prevent it ?

Edit: Win7 64 bits, CB 12.11

oBFusCATed:
The parser in C::B is more C++ centric than C. So for a C++ there are two types Thing and the typedef Thing.

As far as I know the proper way to define structs in C is typedef struct { } Thing;

zabzonk:

--- Quote ---And finally, those multiple matches are obviously redundant in my case

--- End quote ---

Not really, the typedef name and the struct name exist in different namespaces in C, so you really do have two different names. I agree that that one of them should really be "struct Thing", but I guess that is just a quirk of the parser that C::B uses which treats structs and classes as basically the same thing (as they are in C++).

Teybeo:

--- Quote from: oBFusCATed on January 27, 2013, 04:33:03 pm ---As far as I know the proper way to define structs in C is typedef struct { } Thing;

--- End quote ---

But when I do this, I can no longer make forward declarations of the struct because it is anonymous :/


--- Quote from: Neil Butterworth ---
--- Quote from: Teybeo ---And finally, those multiple matches are obviously redundant in my case
--- End quote ---
Not really, ...

--- End quote ---

I meant that in my utilization of a typedef just to not having to write the struct keyword everywhere, the pop-up window is totally useless and annoying. I understand that there are 2 different things :).

p2rkw:
So try:
--- Code: ---typedef struct {
    int var;
} Thing;
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version