-2

I try to use CreateThread() function in my application, but I get strange error, exactly:

error: invalid conversion from 'DWORD (__ attribute__((__ stdcall__)) *)() {aka long unsigned int (__ attribute__((__ stdcall__)) *)()}' to 'LPTHREAD_START_ROUTINE {aka long unsigned int (__ attribute__((__ stdcall__)) *)(void*)}' [-fpermissive]

and

In file included from c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/windows.h:50:0,

             from c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/winsock2.h:22,
             from c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/ws2tcpip.h:19,
             from include/WinSockClass.hpp:3,
             from C:\Users\Jakub\Desktop\offline\Server\main.cpp:15:
c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/winbase.h:1423:26: error:   initializing argument 3 of 'void* CreateThread(LPSECURITY_ATTRIBUTES, DWORD, LPTHREAD_START_ROUTINE, PVOID, DWORD, PDWORD)' [-fpermissive]

second indicates line

WINBASEAPI HANDLE WINAPI CreateThread(LPSECURITY_ATTRIBUTES,DWORD,LPTHREAD_START_ROUTINE,PVOID,DWORD,PDWORD);

in winbase.h, I don't understand what going on, in examples is same thing, but without error. What I do wrong ?

code:

#include <iostream>
#include <windows.h>

using namespace std;

int a()
{
   cout << "work";
   return 0;
}
int main(int argc, char **argv)
{
    CreateThread(NULL,0,a,NULL,0,NULL);
    return 0;
}
Waxy
  • 11
  • 4

1 Answers1

0

OK, is my fault, that works

#include <iostream>
#include <windows.h>

using namespace std;

DWORD WINAPI a(LPVOID lpParameter)
{
   cout << "work";
   return 0;
}
int main(int argc, char **argv)
{
    CreateThread(NULL,0,a,NULL,0,NULL);
    return 0;
}
Waxy
  • 11
  • 4