C ++ syntax: void CLASS functionName ()?

I came across some standalone code without headers. I believe this is direct C / C ++, but I'm not sure. If so, what does β€œCLASS” mean in the following meaning? I know this is not a declaration or class definition. Is this a class method called "CLASS"?

void CLASS functionName(){ // // // } 

I'm used to seeing <returnType> <functionName>() {...} but not higher. Did I forget something? (Forgive me, as I have been in JS and Objective-C recently.)

0
source share
3 answers

Although this is not a regular AFAIK, it may be that CLASS is a macro, as shown below. Since its name is CLASS , I would say that it is rather 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 may be others (such as a macro for a pointer) that are syntactically correct, but they are less likely in your case. Or it could just be a comment, as Hostility below indicates.

+4
source

This is definitely not standard C or C ++, as there are only a few things that could legitimately go between void and a function name (like a star to create a void * return type). This is probably a macro that is used by some compiler extension or external tool. Without additional information about where you found this code, I don’t think I can offer more than that; where did you find it?

+2
source

I used Google Code Search (which can sometimes come in handy) 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/

Unsurprisingly, a definition is a macro (a bit different that might be), but it's just an empty #define . The definition is explained here :

All global variables and all functions that access them with the "CLASS" prefix are defined here. Note that a thread-safe C ++ Class cannot have non-statistical static local variables.

At least in this project, it is mainly used for documentation purposes and is purposefully deleted by the preprocessor. I saw how this was done with pointer pointer options like IN or OUT before, sort of like in MIDL .

@EricZ made a good list of possible uses. Nevertheless, I am sure that this is what you see, due to the coincidence of authorship and the name of the project between Rawness (your case) and Rawtherapee ...

+1
source

Source: https://habr.com/ru/post/951103/


All Articles