Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Commenting methods in c

Tags:

java

c

comments

I wonder if its okay to comment methods in c in the same way you comment code in java-language?

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



  return true;
}

that is in the same manner in c

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



  return 1;
}

Of course its up to the programmer but I would like to know if c-programmers uses these @param or not?

like image 238
user2991252 Avatar asked Nov 28 '13 16:11

user2991252


People also ask

How many types of comment are there in C?

In C/C++ there are two types of comments : Single line comment. Multi-line comment.

What is commenting in C?

Comments in C Comments can be used to explain code, and to make it more readable. It can also be used to prevent execution when testing alternative code. Comments can be singled-lined or multi-lined.

How do you comment a method?

Place the comment on a separate line, not at the end of a line of code. Begin comment text with an uppercase letter. End comment text with a period. Insert one space between the comment delimiter (//) and the comment text, as shown in the following example.

What is comment in C with example?

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.


2 Answers

Of course its up to the programmer but I would like to know if c-programmers uses these @param or not?

In C, whatever you put inside the /**/ is treated as comments. But I dont think @param has got anything to do for it in C.

As far as @ is concerned the @ in Java is for the Javadoc functionality.

like image 189
Rahul Tripathi Avatar answered Sep 20 '22 14:09

Rahul Tripathi


Doc-comments like these are not commonly used in C. They may be useful in some IDEs to generate documentation for functions, but I don't recall ever seeing these comments in C source code.

like image 39
Tim Pierce Avatar answered Sep 21 '22 14:09

Tim Pierce