CLion 2024.3 Help

Extract typedef

The Extract Typedef refactoring changes the selected declaration of a type to a typedef definition.

You can use Extract Typedef when the actual declaration is cumbersome, potentially confusing, or likely to vary from one implementation to another, or just to make code presentation more clear and readable.

Extract typedef in-place

  1. In the editor, select the type declaration to be re-declared.

    Select a type to be extracted
  2. Call Refactor | Extract/Introduce | Typedef from the main menu.

  3. If more than one occurrence of the selected expression is found, select Replace this occurrence only or Replace all occurrences in the Multiple occurrences found popup menu.

  4. Specify the name of the new type.

    Specifying the name for the new type
  5. CLion will extract the new typedef:

    Exract typedef result

Before

After

void f(int); void (*pf1)(int) = &f;
typedef void (*pFunction)(int); void f(int); pFunction pf1 = &f;
Last modified: 08 October 2024