Error:dereferencing pointer to incomplete type solution

Source: Internet
Author: User

Problem:

The following compile error occurred while compiling the program:

dingq@u1110-120628:~/hwsvn/2sw/1prj_linux/pdu/src/branches/pdu-isocket/isocket$ gcc-o tcpclient tcpclient.c 
tcpclient.c:in function ' main ':
tcpclient.c:59:46:error:dereferencing pointer to incomplete type
Source code is:

	Set params of sockaddr_in instances
	serv_addr.sin_family = af_inet;
	Serv_addr.sin_port = htons (port);
	SERV_ADDR.SIN_ADDR = * ((struct in_addr*) host->h_addr);
	Bzero (& (Serv_addr.sin_zero), 8);

Solution:

1. Put the dog search, see that the type is not completely caused, only type definition, and no type declaration;

Further, it is the lack of the inclusion of some of the header documents that caused the problem;

2. include header file <netdb.h> recompile, error disappears.

Solve the problem.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.