Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically generate function headers for .h file in Clion?

Tags:

When writing a library in C, I usually end up implementing functions before defining them in the corresponding header file. As copying function header's in the header file is a repetitive task, I was wondering if I can automatically generate function headers (or even better, the full header file) in CLion?

like image 214
Ali Alavi Avatar asked Dec 15 '15 11:12

Ali Alavi


People also ask

How do I create a custom header file in C++?

You make the declarations in a header file, then use the #include directive in every . cpp file or other header file that requires that declaration. The #include directive inserts a copy of the header file directly into the . cpp file prior to compilation.

How do I open a header file in clion?

Go to Header/Source To invoke Go to Header/Source, press F10 or call Navigate | Header/Source from the main menu.


1 Answers

Maybe it's a little late (about 4 years), but here's the best way i've found (for a c file):

cut and paste the contents of the .c in the .h file, and for each function, put the cursor on it's name and press Alt+Enter, and choose "Split function into declaration and definition".

this will keep the declaration in the .h file while moving the implementation to the .c file.

hope it helps someone.

like image 90
prophet-five Avatar answered Sep 21 '22 19:09

prophet-five