Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [Moved] MOC doesn’t preprocess C/C++ Macros. Any way around that?
Forum Updated to NodeBB v4.3 + New Features

[Moved] MOC doesn’t preprocess C/C++ Macros. Any way around that?

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 3 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ronM71
    wrote on 5 Apr 2011, 21:47 last edited by
    #1

    I want to write a Macro that would define a collection of slots and signals, to make it easier for developers. I can't see how I'm using base class for this as not all classes who'd benefit from that Macro (present and future) derive from one class I have control over.

    so I defined a sample macro with one slot and one signal. If I use the same "string" in my class definition, it works. if I use the "macro" in my class, my build fails link. I was told it's because the MOC doesn't pre-process the C++ macro.

    Any way around that?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on 6 Apr 2011, 06:04 last edited by
      #2

      moc does not do pre processing, it just parses your source (or usually the header) for some keywords and builds up information based on this. If you want to do pre processing, you have to change the build chain with qmake, as you the would need some pre processing --> create püre_header and use pre_header for moc. This is afaik not possible with qmake and default Qt :-( We also had an idea for such things, and went back to the usual way, even if it is more work.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • F Offline
        F Offline
        florent.revelut
        wrote on 6 Apr 2011, 08:11 last edited by
        #3

        We had a similar issue with templates, which are somehow C++ macros (just better or worse, depending if you write them or have to understand the ones of another developper....)

        One of the solution we had was to define virtual interface for our slots, and then, have our real class derivate from interface and qobject, just redefining the previous virtual functions as slots.

        The fun thing is you can do the connect from your interface as it's done on runtime. Kind of risky however to maintain, so we finished by generating these aprts of code with some external python scripting.

        1 Reply Last reply
        0

        1/3

        5 Apr 2011, 21:47

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved