Is there a way I can automatically generate the function headers for a function in eclipse cdt ? I have seen related posts which ask to use Alt + Shift + J or type /**
before function header and press Enter. However i am wondering if it is possible to get a predefined function header. I tried to define my format in
C/C++ > Code style > Code templates > Comments > Methods
but could not find a way to use it in code.
I am afraid I have a partial answer for you:
window -> preferences -> C/C++ -> Editor
and select Doxygen
under Documentation tool comments
, typing /** + enter
will fill in the comment with param and return tags automatically. I have found no way to add other fields automatically though.windows -> preferences -> C/C++ -> Editor -> Templates
, you will be able to create templates that eclipse will be able to auto-complete, when typing their name.@author ${user}
(note the use of a variable). Now you can start typing 'aut', press ctrl+space
for auto-complete, and your tag will be inserted.I understand this may not be the answer you are looking for, but it might help. I too have struggled with the eclipse settings to automatically generate these, but you will become very fast at doing this with templates, and you have more control over the actual content.
I have found a little workaround.
Create a template in perferences >> C/C++ >> Editor >> Templates Give unique Name (like comfun) use the Variables like i did (${...}
save template
now enter the unique name INSIDE the function declaration and hit ctrl+space (watch out that no text is marked), so eclipse can evaluate the Variables All you have to do is move the auto generated text above the function.
I hope that helps a bit.
/*-----------------------------------------------------------------------------+
| F U N C T I O N I N F O R M A T I O N |
+------------------------------------------------------------------------------+
| ToDo: check auto generated function comment |
| |
| Function Name: ${enclosing_method} |
| |
| Prototype at: ${file_base}_tdf.h |
| |
| Description: add some useful content |
| |
| |
| Parameter: ${enclosing_method_arguments} |
| |
| Return Value: ${return_type} OK |
| |
+-----------------------------------------------------------------------------*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With