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

Ali Alavi picture Ali Alavi · Dec 15, 2015 · Viewed 8.4k times · Source

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?

Answer

prophet-five picture prophet-five · Aug 14, 2019

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.