09-20-2013 05:07 AM
what is Macro Expansion ??
Q_DECL_EXPORT int main(int argc, char **argv)
Q_DECL_EXPORT is a Macro Expansion,,
Solved! Go to Solution.
09-20-2013 05:36 AM
It means the real code defined by the macro.
09-20-2013 06:18 AM
A macro means the same in C/C++ as it does in other forms of content creation be that in a word document or here in the forums when writing responses.
Basically it replaces the word defined as a 'macro' with other much longer text and therefore is just a convenience to the writer not to have to type it all out.
If you hold your mouse pointer over a macro in Momentics it will let you know what it is expanding it to or in other words replacing it with.
09-20-2013 11:00 AM
This is important to note since if you don't realize this you can be pulling your hair out trying to figure out what the Qt macros are expanding to. Q_SIGNALS and "signals:" for instance both expand to "public:" in the C++ preprocessor, but when MOC get's a hold of them they resolve to much more complicated code.
I wanted to point out that the answers so far have oversimplified what macros are. The are not just simple text replacement placeholders, they can actually take parameters, which are plugged into the substitution text where you want them. Q_PROPERTY is an example of this since it looks like a function call when you use it. Everything you put inside the parenthesis is a single parameter for the Q_PROPERTY macro, which is parsed by the MOC to build property system code behind your back. In the C++ preprocessor however Q_PROPERTY and all of its parameters expand to nothing.
Also note that some of them exist for the sake of the MOC system only, so they actually expand out to nothing (or void, or white space)
09-23-2013 02:35 AM
Thank you every one for your contribution...