error C2664: 'imgGrab' : cannot convert parameter 2 from 'Int8 **' to 'void **' - c++

I am writing an x64 DLL using Visual Studio 2008.
The compiler error
error C2664: 'imgGrab' : cannot convert parameter 2 from 'Int8 **' to 'void **'
occurs at this line;
Int8* ImaqBuffer;
Int32 err = imgGrab (Sid, &ImaqBuffer, TRUE);
I've managed to get it to compile by doing;
Int32 err = imgGrab (Sid, (void **)&ImaqBuffer, TRUE);
but I think this is wrong. Am I right in thinking this is wrong? If so how do I fix it. I suspect its a compiler setting in Visual Studio because the code compiles ok in the sample project from the manufacturer.

Related

Pointer compatibility from VS2015 to VS2008

In a header file that I cannot modify, I have:
void SetReceiveCallback(void (*funcRXReceiveDataptr)(char* data, int length));
In my cpp code, I have:
void pcsocketcommunication::receiveData(char* data, int length)
{
}
communication = new CommunicationInterface(true, "192.168.214.1", 41682, 2000000, 41681, 2000000);
communication->SetReceiveCallback((void *)(&pcsocketcommunication::receiveData));
I can compile with VS2015 but VS2008 says:
error C2440: 'type cast' : cannot convert from 'void (__thiscall pcsocketcommunication::* )(char *,int)' to 'void *'
How can I modify the calling function to be able to compile in VS2008 ?

Compiling SQLite with Visual Studio C++ 2013 Throws error for .c file

I have added sqlite3.c file into my project.
And #include. Here is the code:
#include <sqlite3.h>
using namespace std;
int main()
{
return 0;
}
I compile the program and it throws the following error:
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(15705): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(19741): error C2440: '=' : cannot convert from 'void *' to 'sqlite3_mutex *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(20665): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(20677): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(21142): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(21256): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(21411): error C2440: '=' : cannot convert from 'void *' to 'char *'
But there is no error that a header or file is not found. Everything is found and the errors are just outputted above
I have found the solution. I compiled the C code as C++, but changing it was not enough.
I write it for future visitors:
First, I had to change file's (ONLY FILE) property. Right-click on the file and select properties, under the C/C++, select Advanced and then select Compile As and set it to C (neither default nor C++).
Then, you should make sure that your .c file is compiled without clr. Well, to do that, under the same C/C++ set of menu, select "Common Langugae Runtime Support" and set it to No Support....
I'm using Visual Studio 17 and I would add to this, find the settings for "Precompiled Header" and set that to "Not Using Precompiled Headers".

Making a Extracting/Compiling program in Visual C++ 2010 but have errors

I am building a .SM2 and .RM2 extractor/compiler for a game but I am having trouble with the code. I am not experienced in C++ at all and the code is source code given by the original creator. Even his original file that wasnt edited by me had errors but he still made the program. Can someone please help me with the errors?
Errors:
Error1: error C2664: 'CreateDirectoryW' : cannot convert parameter 1 from 'const char [25]' to 'LPCWSTR'
Error2: error C2664: 'CreateDirectoryW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR'(X3)
Error4: error C2664: 'FindFirstFileW' : cannot convert parameter 1 from 'char [256]' to'LPCWSTR'
Error5: error C2440: 'initializing' : cannot convert from 'WCHAR [260]' to 'char*'
Here is my code that apparently have the errors:
CreateDirectory(".\\TESTFOLDER\\TESTFOLD2ER", NULL); (This is for Error 1)
CreateDirectory(string, NULL);
break; (This is for Error2)
if ((hdl = FindFirstFile(asteriskpath, &data)) == INVALID_HANDLE_VALUE)
return; (For Error3)
char* filename = data.cFileName;
char current_dir[256]; (For Error4)
Please help,
Thanks,
Cameron
Sawaya
Method 1: set your project character setting to Use Multi-Byte Character Set:
Configure Properties > General > Project Defaults > Character Set > Use Multi-Byte Character Set
Method 2:
For Error 1/2/4:
You should convert char[] to wchar_t[] first before passing to CreateDirectory() (For your Error 1, similar for other errors 2 and 4) as they are using different character encoding types. Try swprintf with the %hs flag.
Example:
wchar_t ws[100];
swprintf(ws, 100, L"%hs", ".\TESTFOLDER\TESTFOLD2ER");
For Error 5:
You can use the wcstombs function to convert wchar_t[] to char[], reference here.

cannot convert parameter

I have this that compiles fine in VC++ 6.0
typedef std::vector<ILBCOM_FieldStruct*> FieldsVector;
FieldsVector m_coll;
FieldsVector::iterator it(&m_coll[Index-1]);
m_coll.erase(it);
I need to compile in Visual Studio C++ 2010
The error message is on the 3rd line:
error C2664: 'std::_Vector_iterator<_Myvec>::_Vector_iterator(const
std::_Vector_iterator<_Myvec> &)' : cannot convert parameter 1 from
'ILBCOM_FieldStruct **' to 'const std::_Vector_iterator<_Myvec> &'
Do you see something wrong?
std::vector<T>::iterator does not have a constructor that converts from T*. It does have a copy constructor:
FieldsVector::iterator it(m_coll.begin()+Index-1);

compile errors log4cxx with __stdcall and Boost 1.47.0

I'll be very pleased if you help.
My IDE is VS2010.
I'm using boost 1.47.0, especially boost::asio.
After some days of developing I decided to add log4cxx.
log4cxx needs to change calling convention to __stdcall
I surprisingly got lots of compiling error. They are ~ 70 errors.
I've googled a bit and found these:
#define BOOST_BIND_ENABLE_STDCALL
#define BOOST_MEM_FN_ENABLE_STDCALL
It helps. Now there are just ~10 errors.
Here there are:
1>ClCompile:
1> main.cpp
1>D:\Development\lib\boost_1_47_0\boost/detail/interlocked.hpp(61): error C2373: '_InterlockedCompareExchange' : redefinition; different type modifiers
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\intrin.h(214) : see declaration of '_InterlockedCompareExchange'
1>D:\Development\lib\boost_1_47_0\boost/detail/interlocked.hpp(62): error C2373: '_InterlockedExchange' : redefinition; different type modifiers
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\intrin.h(192) : see declaration of '_InterlockedExchange'
1>D:\Development\lib\boost_1_47_0\boost/detail/interlocked.hpp(63): error C2373: '_InterlockedExchangeAdd' : redefinition; different type modifiers
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\intrin.h(204) : see declaration of '_InterlockedExchangeAdd'
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/sp_counted_base_w32.hpp(92): error C2446: '==' : no conversion from 'long' to 'long (__stdcall *)(volatile long *,long,long)'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/sp_counted_base_w32.hpp(92): error C2040: '==' : 'long (__stdcall *)(volatile long *,long,long)' differs in levels of indirection from 'long'
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/sp_counted_base_w32.hpp(92): error C3861: '_InterlockedCompareExchange': identifier not found
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/spinlock_w32.hpp(62): error C3861: '_InterlockedExchange': identifier not found
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/spinlock_w32.hpp(62): error C2440: 'initializing' : cannot convert from 'long (__stdcall *)(volatile long *,long)' to 'long'
1> There is no context in which this conversion is possible
1>D:\Development\lib\boost_1_47_0\boost/asio/detail/impl/signal_set_service.ipp(74): error C2664: 'signal' : cannot convert parameter 2 from 'void (__stdcall *)(int)' to 'void (__cdecl *)(int)'
1> None of the functions with this name in scope match the target type
1>D:\Development\lib\boost_1_47_0\boost/asio/detail/impl/signal_set_service.ipp(246): error C2664: 'signal' : cannot convert parameter 2 from 'void (__stdcall *)(int)' to 'void (__cdecl *)(int)'
1> None of the functions with this name in scope match the target type
1>main.cpp(20): warning C4007: 'main' : must be '__cdecl'
How can I solve them?
Any little ideas or hints?
You also need
#define BOOST_USE_WINDOWS_H
and possibly /Gz (__stdcall)
If your code looks something like:
#include "log4cxx/logger.h"
#include "log4cxx/basicconfigurator.h"
#include "log4cxx/helpers/exception.h"
using namespace log4cxx;
using namespace log4cxx::helpers;
int main()
{
//stuff
}
and you compile with -llog4cxx then you should be fine.