简体   繁体   English

在函数声明中阻止注释?

[英]Block comment inside function declaration?

I'm going through this C code and the function declarations seem to contain block comments. 我正在看这段C代码,函数声明似乎包含块注释。 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 变量Rank定义为

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. 在C语言中,它不能作为语言功能使用,但是某些人可能会使用这种注释来提高可读性。

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 变量Rank定义为

 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. 声明中的名称Rank是一个type ,而不是一个变量,并且您显示的枚举是针对西装而不是ranks的。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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