Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to solve name clash emit?
Forum Updated to NodeBB v4.3 + New Features

how to solve name clash emit?

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 4 Posters 1.8k Views 3 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.
  • M Offline
    M Offline
    Marek
    wrote on last edited by
    #1

    Hi all,
    I'm trying to use Aspose.Pdf to convert pdf to doc
    https://github.com/aspose-pdf/Aspose.Pdf-for-C
    I have problem compiling probably due to name clash for "emit" macro, I have Linux version of this library
    https://downloads.aspose.com/pdf/cpp
    But when I include haders, there is always error:

    aspose/include/asposecpplib/system/multicast_delegate.h: At global scope:
    aspose/include/asposecpplib/system/multicast_delegate.h:323:38: error: expected ‘)’ before ‘...’ token
             ReturnType emit(ArgumentTypes... args) const
                            ~             ^~~
                                          )
    aspose/include/asposecpplib/system/multicast_delegate.h: In member function ‘ReturnType System::MulticastDelegate<ReturnType(ArgumentTypes ...)>::operator()(ArgumentTypes ...) const’:
    aspose/include/asposecpplib/system/multicast_delegate.h:349:32: error: expected binary operator before ‘)’ token
                 return emit(args...);
    

    There is a piece of code

            ReturnType emit(ArgumentTypes... args) const
            {
    #ifdef ASPOSE_THREADSAFE_DELEGATES
                std::lock_guard<std::mutex> lock(m_guard);
    #endif
    
    #ifdef ASPOSE_REMOVE_EMPTY_CALLBACKS
                remove_empty_callbacks();
    #endif
                if( m_callbacks && !m_callbacks->empty() )
                {
                    auto last = std::prev(m_callbacks->end()); // always valid, m_callbacks is not empty
                    for (auto it = m_callbacks->begin(); it != last; ++it)
                        (*it)(args...); // ignore result!
    
                    return (*last)(args...);
                }
    
                throw NullReferenceException(u"MulticastDelegate: Object reference not set to an instance of an object.");
            }
    

    And I'm trying to include header which has many more includes

    #include "aspose/aspose.pdf.h"
    using namespace System;
    using namespace System::Drawing;
    

    Is there a way to solve this issue?

    Best,
    Marek

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Marek said in how to solve name clash emit?:

      Is there a way to solve this issue?

      See the documentation

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      M 1 Reply Last reply
      3
      • Christian EhrlicherC Christian Ehrlicher

        @Marek said in how to solve name clash emit?:

        Is there a way to solve this issue?

        See the documentation

        M Offline
        M Offline
        Marek
        wrote on last edited by
        #3

        @Christian-Ehrlicher thanks for answer

        So If I do that I have lots and lots of errors in class definition

        public slots:
            QString getPeerAddr();
            void sendToClient(int client_id,QDomDocument xml);
            void sendToClient(QDomDocument xml);
            void setUserId(int user_id);
            void setUserValid(bool valid);
        signals:
        

        slots does not name a type
        signals does not name a type

        and in cpp files:
        emit was not declared in this scope

        Best,
        Marek

        M 1 Reply Last reply
        0
        • M Marek

          @Christian-Ehrlicher thanks for answer

          So If I do that I have lots and lots of errors in class definition

          public slots:
              QString getPeerAddr();
              void sendToClient(int client_id,QDomDocument xml);
              void sendToClient(QDomDocument xml);
              void setUserId(int user_id);
              void setUserValid(bool valid);
          signals:
          

          slots does not name a type
          signals does not name a type

          and in cpp files:
          emit was not declared in this scope

          Best,
          Marek

          M Offline
          M Offline
          Marek
          wrote on last edited by
          #4

          @Marek ok
          " simply replace all uses of the Qt moc keywords in your sources with the corresponding Qt macros Q_SIGNALS (or Q_SIGNAL), Q_SLOTS (or Q_SLOT), and Q_EMIT."

          there will be a lot of this :(

          1 Reply Last reply
          1
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Marek said in how to solve name clash emit?:

            there will be a lot of this :(

            Don't blame Qt but the other library - emit, signals and slots as macro are used by Qt since ages.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            M 1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              @Marek said in how to solve name clash emit?:

              there will be a lot of this :(

              Don't blame Qt but the other library - emit, signals and slots as macro are used by Qt since ages.

              M Offline
              M Offline
              Marek
              wrote on last edited by
              #6

              @Christian-Ehrlicher I don't, this was easy, but library does not do what I want.
              Some recommended way to convert pdf to doc via lib or web api ?

              Best,
              Marek

              1 Reply Last reply
              0
              • KH-219DesignK Offline
                KH-219DesignK Offline
                KH-219Design
                wrote on last edited by
                #7

                If the only problem is with the word "emit", then you can just not use "emit" when you call your signals.

                This works the same:

                emit somethingChanged();
                somethingChanged();
                

                At least I can say for sure on the Linux desktop platform in Qt 5.14, "emit" expands to empty space:

                include/QtCore/qobjectdefs.h:97:# define emit
                

                www.219design.com
                Software | Electrical | Mechanical | Product Design

                1 Reply Last reply
                0
                • KH-219DesignK Offline
                  KH-219DesignK Offline
                  KH-219Design
                  wrote on last edited by
                  #8

                  @KH-219Design said in how to solve name clash emit?:

                  qobjectdefs.h

                  Looking in that same file (qobjectdefs.h), it seems you might also be able to rebuild Qt with preprocessor def "QT_NO_EMIT" set? (I have not tried it)

                  #ifndef QT_NO_EMIT
                  # define emit
                  #endif
                  

                  www.219design.com
                  Software | Electrical | Mechanical | Product Design

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @KH-219Design said in how to solve name clash emit?:

                    be able to rebuild Qt with preprocessor def "QT_NO_EMIT" set? (I have not tried it)

                    It's in a header - why should you need to rebuild the whole Qt? "CONFIG += no_keywords" does simply define QT_NO_KEYWORDS which then defines QT_NO_EMIT (see line 85)

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    2
                    • KH-219DesignK Offline
                      KH-219DesignK Offline
                      KH-219Design
                      wrote on last edited by
                      #10

                      @Christian-Ehrlicher said in how to solve name clash emit?:

                      It's in a header - why should you need to rebuild the whole Qt?

                      I'm not sure whether you do or do not need to rebuild.

                      However, there is certainly a case where you would need to.

                      If certain lines in a header file are conditionally "in" or "out" due to being gated by "#ifdef CPP_VAR", then everything in your application that "sees" that header needs to agree on which lines are in and which are out. So if Qt libraries were built one way (for example with CPP_VAR unset) and those Qt libraries contain binary code based on that version of the header, and then you build your executable with a different setting (for example setting CPP_VAR), then your code will see different lines of that header, meaning you are using a header ("the api") that does not match up with the Qt libs (the "the aBi"). (api = app programming interface; abi = app binary interface)

                      www.219design.com
                      Software | Electrical | Mechanical | Product Design

                      1 Reply Last reply
                      0
                      • Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @KH-219Design said in how to solve name clash emit?:

                        I'm not sure whether you do or do not need to rebuild.

                        You don't have to rebuild Qt for this define.

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        1 Reply Last reply
                        1
                        • M Offline
                          M Offline
                          Marek
                          wrote on last edited by
                          #12

                          Hi

                          Thanks all for help, I have added keyword to pro file and replaces all emit, signals, slots and it works.

                          "If the only problem is with the word "emit", then you can just not use "emit" when you call your signals."
                          The problem was in compiling 3rd part library into my program and "emit" was used in this third part library.

                          Anyway, I'm marking this as solved.
                          Thanks
                          Marek

                          A 2 Replies Last reply
                          0
                          • M Marek

                            Hi

                            Thanks all for help, I have added keyword to pro file and replaces all emit, signals, slots and it works.

                            "If the only problem is with the word "emit", then you can just not use "emit" when you call your signals."
                            The problem was in compiling 3rd part library into my program and "emit" was used in this third part library.

                            Anyway, I'm marking this as solved.
                            Thanks
                            Marek

                            A Offline
                            A Offline
                            asad.ali
                            wrote on last edited by
                            #13

                            @Marek

                            @usman-qt

                            Regarding Aspose.PDF for C++, The common library asposecpplib has MulticastDelegate::emit() function and 'emit' is QT keyword as well. This is the main reason for the conflict and error you were facing. So yes, your assumptions were correct. We are working over resolving the conflict and as soon as it is resolved, we will surely inform you. Please spare us some time.

                            PS: I am Asad Ali and I work at Aspose as Developer Evangelist.

                            1 Reply Last reply
                            2
                            • M Marek

                              Hi

                              Thanks all for help, I have added keyword to pro file and replaces all emit, signals, slots and it works.

                              "If the only problem is with the word "emit", then you can just not use "emit" when you call your signals."
                              The problem was in compiling 3rd part library into my program and "emit" was used in this third part library.

                              Anyway, I'm marking this as solved.
                              Thanks
                              Marek

                              A Offline
                              A Offline
                              asad.ali
                              wrote on last edited by
                              #14

                              @Marek
                              @usman-qt

                              We are excited to share that QT Support has been added to the Aspose.PDF for C++. You can now download and use Aspose.PDF for C++ 20.6 with QT Project. Please let us know about your feedback in case you face any issue.

                              M 1 Reply Last reply
                              2
                              • A asad.ali

                                @Marek
                                @usman-qt

                                We are excited to share that QT Support has been added to the Aspose.PDF for C++. You can now download and use Aspose.PDF for C++ 20.6 with QT Project. Please let us know about your feedback in case you face any issue.

                                M Offline
                                M Offline
                                Marek
                                wrote on last edited by
                                #15

                                @asad-ali thanks for your effort ;)

                                1 Reply Last reply
                                1

                                • Login

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