Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write documentation comments in ANSI C? [closed]

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?

like image 204
bb2 Avatar asked Jan 17 '12 05:01

bb2


People also ask

How do you comment in ANSI C?

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.

How do you do Doxygen comments?

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.

How do you write a comment in programming?

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.

How do I comment out a code in Doxygen C++?

To create a Doxygen comment from scratch: Type one of the following symbols: /// , //! , /** or /*! and press Enter .


2 Answers

There are many different standards, if you want to generate documentation, try doxygen

like image 166
Dhaivat Pandya Avatar answered Sep 23 '22 01:09

Dhaivat Pandya


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.

like image 37
rubo77 Avatar answered Sep 21 '22 01:09

rubo77