简体   繁体   中英

Block comment inside function declaration?

I'm going through this C code and the function declarations seem to contain block comments. they look like this:

void show_rank (/*in*/ Rank rank);

is that actually a block comment in the arguments or does it have an alternate meaning?

The variable Rank is defined as

typedef enum
{
   Clubs, Spades, Diamonds, Hearts
} Suit;

It is just a comment. However, some other languages have declarations on parameters that show whether the intention of the parameter is for it to be an input to the function or the output from it (ie whether the function expects to read from it or write to it); in C, it is not available as a language feature, but some people might use comments of that sort to improve readability.

It's a pure comment. Presumably, it is intended to annotate the purpose of the parameter (somewhat pointlessly since the parameter isn't a pointer so it can only be an input parameter). No standard compiler interprets the comment.

You make the interesting claim:

The variable Rank is defined as

 typedef enum { Clubs, Spades, Diamonds, Hearts } Suit; 

The name Rank in the declaration is a type , not a variable, and the enumeration you show is for suits, not ranks.

除非您使用特殊的编译器/预处理器/解释器,否则它实际上应该是块注释。

这只是一个普通注释,对代码没有影响。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM