I can't find how to write comments in C. I mean I know about //
and /* */
, what I mean is where can I find good practices? Like if I have a function, how do I write the @param variable is the value bla bla
, like it is done in Java?
Are there any standards for this? Or can I just do it like I do it in Java?
A comment starts with a slash asterisk /* and ends with a asterisk slash */ and can be anywhere in your program. Comments can span several lines within your C program. Comments are typically added directly above the related C source code.
doxygen Getting started with doxygen Commenting your code//! //! ... text ... //! Note the 2 slashes to end the normal comment block and start a special comment block.
The single line comment is //. Everything from the // to the end of the line is a comment. To mark an entire region as a comment, use /* to start the comment and */ to end the comment.
To create a Doxygen comment from scratch: Type one of the following symbols: /// , //! , /** or /*! and press Enter .
There are many different standards, if you want to generate documentation, try doxygen
You can use javadoc standard and then use doxygen that understands javadoc to generate a documentation.
In doxygen I recommend using the option JAVADOC_AUTOBRIEF
set to YES
. If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the first line (until the first dot) of a Javadoc-style comment as the brief description.
Example for a class definition:
/** * A brief description. A more elaborate class description * @param bool somebool a boolean argument. * @see Test() * @return The test results */
(Some more examples in the doxygen manual)
Installation is really simple, there is a GUI and a nice graphical visualisation available with:
apt-get install doxygen doxygen-gui graphviz
Run the gui calling doxywizard
and use the Wizard settings, only JAVADOC_AUTOBRIEF
has to be set there in "Expert" settings.
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