- 论坛徽章:
- 0
|
#include <QApplication>
#include "mywidget.h"
#include "function.h"
#define PORT_NUM 20
#define SEVER_PORT 5001
multi_data Multi_data;//自定义数据结构
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
MyWidget *hbox = new MyWidget;
hbox->show();//新建一个qt界面
pthread_mutex_init(&Multi_data.mutex,NULL);//初始化互斥锁
void *addr1 = NULL;
create_shmid(addr1);
pthread_t thread_read;//创建接收读取线程
pthread_attr_t attr_read;
......
void create_shmid(void *addr)
{
int shmid;
int key;
key = ftok(".",1);
shmid = shmget(key,64*64,IPC_CREAT|0666);
addr = shmat(shmid,0,0);
/* if(0x0 == addr)
{
perror("addr");
exit(1);
}*/
}
其实其他代码对这个函数没有影响,如果要贴完就太多了。
我就是单步到“pthread_t thread_read;//创建接收读取线程”print addr就是0x0。 |
|