how to solve name clash emit?
-
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 -
@Marek said in how to solve name clash emit?:
Is there a way to solve this issue?
See the documentation
-
@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 typeand in cpp files:
emit was not declared in this scopeBest,
Marek -
@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.
-
@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 -
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
-
@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
-
@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)
-
@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)
-
@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.
-
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 -
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.
-