ceclipseeclipse-cdt

Eclipse C/C++ how to find variable belongs to which struct quickly


In a large C header file where defines many struct, like following,

struct s1 {
  ...
};

struct s2{
  int var_1;
  int var_2;
  int var_3;

  ...
  int var_200;
  ...

  int var_500;
};

struct s3{
  ...
};

I want to know var_200 belongs to which struct, in this case, it is s2.

Scrolling up in this case, not only slow, but also easy to miss the correct curly bracket(because there can be struct in the struct, there could be many curly bracket). Is there any good method to do this?


Solution

  • In Eclipse CDT, you can quickly find which struct a variable belongs to using Open Declaration (F3):

    1. Hover over var_200 → Eclipse will show the struct name in tooltip
    2. Right-Click var_200 → Click "Open Declaration" (or press F3)
    3. This will jump directly to where var_200 is defined inside its struct

    This method works even if structs are deeply nested