When you do not use the default libraries with Visual Studio C++ you can come far with just linking to MSVCRT. However, you run into trouble when using C++ and classes. These use the new and delete operators.
According to the Internet it can be solved by just overloading the new and delete operators.
void* operator new(size_t size) { return malloc(size); } void* operator new[](size_t size) { return malloc(size); } void operator delete(void* what) { free(what); } void operator delete[](void* what) { free(what); }
However, this did not work. I still got a error on the delete operator. So, what I did was transform the code:
GuiThread* guiThread = new GuiThread(); Became: GuiThread* guiThread = (GuiThread*)calloc(1, sizeof(GuiThread)); guiThread->threadHandle = CreateThread(NULL, 0, GuiThread::StaticThreadStart, (void*)guiThread, 0, &guiThread->threadID); delete guiThread; Became: free(guiThread);
Geen opmerkingen:
Een reactie posten