C++语法:void CLASS 函数名()?
我遇到了一些没有标题的独立代码。我相信它是直接的 C/C++,但我不确定。如果是的话,下面的“CLASS”是什么意思?我知道这不是类声明或定义。这是名为“CLASS”的类的方法吗?
void CLASS functionName(){
//
//
//
}
我习惯看到
,但不是上面的。我是不是忘记了什么? (请原谅我,因为我最近一直在研究 JS 和 Objective-C。)
I came across some standalone code without headers. I believe it to be straight C/C++, but am not sure. If so, what does the "CLASS" in the following mean? I know it's not a class declaration or definition. Is this a method of a class named "CLASS"?
void CLASS functionName(){
//
//
//
}
I'm used to seeing <returnType> <functionName>() {...}
, but not the above. Am I forgetting something? (Pardon me, as I've been in JS and Objective-C lately.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
虽然这并不常见,但 CLASS 可能是如下宏。由于它的名称是 CLASS,我认为它更有可能是类或命名空间的宏。
1.类名
2.命名空间
3.调用转换
4.其他
可能还有其他语法正确的(例如,指针的宏),但在您的情况下不太可能。或者它可能只是一条评论,正如 Hostile 在下面指出的那样。
Although it's not common AFAIK, it could be that CLASS is a macro as below. Since its name is
CLASS
, I would say it's more likely that it's a macro for a class or namespace.1. Class Name
2. Namespace
3. Calling Convertion
4. Others
There could be others (e.g., a macro for a pointer) which are syntactically correct, but they're less likely in your case. Or it could simply be a comment, as Hostile points out below.
这绝对不是标准的 C 或 C++,因为只有少数东西可以合法地放在
void
和函数名称之间(例如,星号,以使返回类型无效*
)。这可能是某些编译器扩展或外部工具正在使用的宏。如果没有更多关于您在哪里找到此代码的信息,我认为我无法提供更多信息;你在哪里找到这个的?This is definitely not standard C or C++, as there's only a few things that could legally go in-between the
void
and the function name (a star, for example, to make the return typevoid *
). This is probably a macro that's being used by some compiler extension or external tool. Without more information about where you found this code I don't think I can offer more than that; where did you find this?我使用了 Google 的代码搜索(有时会派上用场),并在 "rawtherapee" 中找到了一个实例:
<一href="http://codesearch.google.com/#search/&q=%22void%20CLASS%22&type=cs&exact_package=http://rawtherapee.googlecode.com/hg/" rel="nofollow">http://codesearch.google.com/#search/&q=%22void%20CLASS%22&type=cs&exact_package=http://rawtherapee.googlecode.com/hg/
毫不奇怪,定义是一个宏(几乎没有其他可能),但它只是一个空的
#define
。定义已解释此处:至少在该项目中,它基本上用于文档目的,并有目的地被预处理器删除。我之前见过将指针参数标记为
IN
或OUT
,有点像 MIDL。@EricZ 已经详细列出了可能的用途。但我相当确定这就是您所看到的,因为 Rawness (您的案例)和 Rawtherapee 之间的作者身份和项目名称重叠......
I used Google's Code Search (which can come in handy sometimes) and found an instance of this in "rawtherapee":
http://codesearch.google.com/#search/&q=%22void%20CLASS%22&type=cs&exact_package=http://rawtherapee.googlecode.com/hg/
Not surprisingly, the definition is a macro (there's little else it could be), but it's just an empty
#define
. The definition is explained here:At least in that project, it's basically being used for documentation purposes, and purposefully is stripped out by the preprocessor. I've seen this done marking pointer parameters as
IN
orOUT
before, sort of like in MIDL.@EricZ has made a good inventory of possible uses. Yet I am fairly sure this is what you're seeing, because of the authorship and project name overlap between Rawness (your case) and Rawtherapee...