Results 1 to 3 of 3

Thread: A #define macro statement question

  1. #1
    Join Date
    Oct 2016
    Posts
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default A #define macro statement question

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: A #define macro statement question

    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

    Qt Code:
    1. HMIClass_DECLARE(foo)
    To copy to clipboard, switch view to plain text mode 
    gets replaced with
    Qt Code:
    1. HMIClass &foo();
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. #3
    Join Date
    Oct 2016
    Posts
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: A #define macro statement question

    Yes, thanks, I stick into object creation.

Similar Threads

  1. MOC and macro expanding
    By kert in forum Qt Programming
    Replies: 4
    Last Post: 6th August 2015, 10:32
  2. How to define class RTTI info macro?
    By lni in forum Qt Programming
    Replies: 5
    Last Post: 7th January 2010, 15:18
  3. the question about define my own selection behavior
    By calmspeaker in forum Qt Programming
    Replies: 1
    Last Post: 20th June 2009, 11:40
  4. Macro
    By comlink21 in forum Qt Programming
    Replies: 1
    Last Post: 25th July 2007, 11:28
  5. Replies: 1
    Last Post: 4th November 2006, 06:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.