PDA

View Full Version : A #define macro statement question



focusdoit
25th October 2016, 16:18
Hi,
I read a program, found a #define statement.

#define HMIClass_DECLARE(name) \
HMIClass &name();

I think the macro works like:

Class A { .. };
A &aInstance();

But I am a little confused with A &a();
I think, it is used to create an instance.

anda_skoa
25th October 2016, 16:39
The macro gets replaced by a function that is called like the argument given to the macro and which returns an HMIClass instance per reference



HMIClass_DECLARE(foo)

gets replaced with


HMIClass &foo();


Cheers,
_

focusdoit
25th October 2016, 17:51
Yes, thanks, I stick into object creation.