C++语法:void CLASS 函数名()?

发布于 2024-11-29 20:38:12 字数 313 浏览 0 评论 0原文

我遇到了一些没有标题的独立代码。我相信它是直接的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

樱花坊 2024-12-06 20:38:12

虽然这并不常见,但 CLASS 可能是如下宏。由于它的名称是 CLASS,我认为它更有可能是类或命名空间的宏。

1.类名

class A
{
   void functionName();
};

#define CLASS A::

void CLASS functionName()
{}

2.命名空间

namespace A
{
   void functionName();
};

#define CLASS A::

void CLASS functionName()
{}

3.调用转换

// or __cdecl, etc.
define CLASS __stdcall

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

class A
{
   void functionName();
};

#define CLASS A::

void CLASS functionName()
{}

2. Namespace

namespace A
{
   void functionName();
};

#define CLASS A::

void CLASS functionName()
{}

3. Calling Convertion

// or __cdecl, etc.
define CLASS __stdcall

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.

北城半夏 2024-12-06 20:38:12

这绝对不是标准的 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 type void *). 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?

滥情稳全场 2024-12-06 20:38:12

我使用了 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。定义已解释此处

所有全局变量都在这里定义,所有函数
访问它们的前缀是“CLASS”。请注意,线程安全
C++ 类不能有非常量静态局部变量。

至少在该项目中,它基本上用于文档目的,并有目的地被预处理器删除。我之前见过将指针参数标记为 INOUT ,有点像 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:

All global variables are defined here, and all functions that
access them are prefixed with "CLASS". Note that a thread-safe
C++ class cannot have non-const static local variables.

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 or OUT 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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文