struct sockaddr_in 的问题,我歇菜了
直接上程序:很简单的函数,我把该去掉的都去掉了,就这样加个main函数gcc编译还是报错,我晕死
void camera_thread()
{
int video_sockfd;
struct sockaddr_in camera_addr;
video_sockfd = socket(AF_INET, SOCK_STREAM, 0);
//init_connect(&camera_addr,4444,Local_ip);
//if(-1 == connect(video_sockfd,(struct sockaddr *)(&camera_addr),sizeof(struct sockaddr)))
{
printf("in camera_thread():connect failed,socketfd = %d\n",video_sockfd);
return ;
}
//video_read(video_sockfd);
}
编译报错:video_monitoring.c: In function ‘camera_thread’:
video_monitoring.c:56: error: storage size of ‘camera_addr’ isn’t known
再贴出我的头文件:
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
//#include "msghand.h"
我想头文件应该没问题了吧,#include <sys/socket.h>也有,可还是报如上的错误,好吧,我彻底歇菜了,高人来指点
补充下,我想我的gcc应该没问题,应为我编译其他的.c文件的时候里面也有用到这个定义,可都没报错,唯独选中了这个.c,老报这个错误