Commenting methods in c

I wonder if it is okay to comment methods in c just like you are commenting on Java code?

/** * * @param x * @param y * @return */ protected boolean myMethod(int x, int y) { return true; } 

same thing in c

  /** * * @param x * @param y * @return */ int myMethod(int x, int y) { return 1; } 

Of course, before the programmer, but I would like to know if c-programers use these @param or not?

+6
source share
6 answers

Of course, before the programmer, but I would like to know if c-programmers use these @param or not?

In C, everything you put inside /**/ is treated as comments. But I don't think @param has anything to do for him in C.

As for @ , @ in Java refers to Javadoc functions.

+1
source

Doc comments like these are usually not used in C. They can be useful in some IDEs to generate documentation for functions, but I don’t remember ever seeing these comments in the C source code.

+1
source

You can use doxygen for documentation in any programming language, such as C, Objective-C, C #, PHP, Java, Python, IDL (Corba, Microsoft and UNO / OpenOffice variants), Fortran, VHDL, Tcl and to some extent D

+1
source

I like to comment on my function definitions like:

 /***************************************************************************** * @brief * @author * @date * @return * @arg * @note * *****************************************************************************/ 
+1
source

Everything is fine to comment on everything that is easy to understand. In java, you are commenting in a specific format to allow javadoc to create documentation.

Instead of javadoc in C (and many other languages), DOXYGEN is usually used to create documentation from structured comments.
Fortunately, the syntax is almost identical to javadoc.

Check out http://www.stack.nl/~dimitri/doxygen/ .

0
source

@ in Java is a Javadoc function. This is not part of the C language, so @ will be ignored in the comment. These types of things are usually team / company dependent and subject to agreement.

0
source

Source: https://habr.com/ru/post/958998/


All Articles