Windows中创建线程时不兼容的类型 [英] incompatible types when creating thread in Windows

查看:157
本文介绍了Windows中创建线程时不兼容的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个应用程序,在该应用程序中,我希望线程分别处理listen-UDP并使其成为缓冲区,但是当我尝试将其传递给线程时,它说存在兼容性问题

I have created an app in which I want a thread to handle listen-UDP separately and make me a buffer, but when I try to pass it to thread it says there are compatibility issues

hThread = CreateThread( 
          NULL,                   // default security attributes
          0,                      // use default stack size  
          start,       // thread function name
          &buffer,          // argument to thread function 
          0,                      // use default creation flags 
          &dwThreadId);

我的启动功能是

void start(buffer_t *buffer)
{

    SOCKET s;
    struct sockaddr_in server, si_other;
    int slen , recv_len;
    char buf[BUFLEN];
    WSADATA wsa;
}

,错误是

1 IntelliSense:类型"void(*)(buffer_t * buffer)"的参数与类型"LPTHREAD_START_ROUTINE"的参数不兼容c:\ users \ madihamalik \ documents \ visual studio 2010 \ projects \ udp监听器\ udp监听器\ listerner.c 189 12 UDP侦听器

1 IntelliSense: argument of type "void (*)(buffer_t *buffer)" is incompatible with parameter of type "LPTHREAD_START_ROUTINE" c:\users\madihamalik\documents\visual studio 2010\projects\udp listener\udp listener\listerner.c 189 12 UDP listener

推荐答案

尝试以下可能对您有帮助的代码.

Try below code that might help you..

DWORD start(LPVOID lpdwThreadParam)
{
    buffer_t *buffer = (buffer_t *)lpdwThreadParam; //Type cast your argument here
    SOCKET s;
    struct sockaddr_in server, si_other;
    int slen, recv_len;
    char buf[BUFLEN];
    WSADATA wsa;
    ...
}

这篇关于Windows中创建线程时不兼容的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆