I am attempting to implement some TWAIN functionality into a QT project. I have opened this code from the provider and compiled it. However when I past the code into my project it wont compile.
Basically I have 3 files CommonTWAIN.h, TwainAPP.cpp, and DSMInterface.cpp.
In CommonTwain.h I define a constant I believe, called. kTWAIN_DSM_DLL_NAME
/* CommonTWAIN.h */
#ifdef TWH_CMP_MSC
#ifdef TWH_64BIT
#define kTWAIN_DSM_DLL_NAME "TWAINDSM.dll"
#else
#define kTWAIN_DSM_DLL_NAME "TWAINDSM.dll"
#endif // #ifdef TWH_64BIT
#elif defined(TWH_CMP_GNU)
#define kTWAIN_DSM_DLL_NAME "libtwaindsm.so"
#else
#error Sorry, we don't recognize this system...
#endif
In TwainApp.cpp I use that constant in a function call.
/* TwainApp.cpp */
LoadDSMLib(kTWAIN_DSM_DIR kTWAIN_DSM_DLL_NAME)
That function calls code that is in DSMInterface.cpp defined by
/* DSMInterface.h */
bool LoadDSMLib(char* _pszLibName);
I get stuck with this error
However The code also provides a visual studio solution that I can open and compile. This works as expected with the same code. So I am assuming I just have something configured wrong. This is fairly out of what I am comfortable with but I do think I am missing something simple.
So far I have tried adding QMAKE_CXXFLAGS += -permissive
to the project file. no luck.
I don't like that cast much. I'm sure it will work fine in practise (well, almost sure) but I don't like it on principle.
Instead, I would do something like this:
std::string libname = kTWAIN_DSM_DIR kTWAIN_DSM_DLL_NAME;
LoadDSMLib(libname.data());
If you ❤️ QString
then you can probably use that instead.
you should be able to cast it away:
LoadDSMLib((char*)(kTWAIN_DSM_DIR kTWAIN_DSM_DLL_NAME))
as long as the function isn't trying to modify the string it should be fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.