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] Q_EXPORT_PLUGIN2 and variables in TARGET
Forum Updated to NodeBB v4.3 + New Features

[Moved] Q_EXPORT_PLUGIN2 and variables in TARGET

Scheduled Pinned Locked Moved Qt Creator and other tools
6 Posts 2 Posters 4.0k 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.
  • J Offline
    J Offline
    JulienMaille
    wrote on last edited by
    #1

    The documentation states:
    @
    Q_EXPORT_PLUGIN2 ( PluginName, ClassName )
    @

    bq. This macro exports the plugin class ClassName for the plugin specified by PluginName. The value of PluginName should correspond to the TARGET specified in the plugin's project file.

    However my TARGET contains variables like the architecture or debug/release mode.
    Is there anyway to handle this through $$qtLibraryTarget() or #ifdef ?

    [EDIT: fixed formatting, Volker]

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      qmake's variables are not available in the C++ preprocessor. You can define a macro in the qmake project file and export this to the precprocessor (just as -D on the command line would do). #ifdef is also an option.

      EDIT: moved to the Tools forum, as it's more a qmake issue.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JulienMaille
        wrote on last edited by
        #3

        Thanks for the format fix, and sorry if I posted in the wrong section.
        You say #ifdef is a solution, but is the Q_EXPORT_PLUGIN2 expanded when I run qmake on my pro file, or when moc'ing with visual studio?

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          It's a regular preprocessor macro, so it's expanded at compile time. It's possible that moc also recognizes it and generates some code.

          qmake does not expand the macros in the code; in fact you can create Qt projects without qmake (eg. with CMake or write the Makefiles manually).

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • J Offline
            J Offline
            JulienMaille
            wrote on last edited by
            #5

            It is strange that this macro looks like it's not using the PLUGIN var:
            @# define Q_EXPORT_PLUGIN2(PLUGIN, PLUGINCLASS)
            Q_PLUGIN_VERIFICATION_DATA
            Q_EXTERN_C Q_DECL_EXPORT
            const char * Q_STANDARD_CALL qt_plugin_query_verification_data()
            { return qt_plugin_verification_data; }
            Q_EXTERN_C Q_DECL_EXPORT QT_PREPEND_NAMESPACE(QObject) * Q_STANDARD_CALL qt_plugin_instance()
            Q_PLUGIN_INSTANCE(PLUGINCLASS)@

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              The actual definition of Q_EXPORT_PLUGIN2 depends on the value of QT_STATICPLUGIN. One of these uses the value of PLUGIN.

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0

              • Login

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