zoukankan      html  css  js  c++  java
  • warning: implicit declaration of function ‘inet_ntop’解决办法

    问题:

    在打印hostent的IP地址时,用到了inet_ntop(),在编译时显示这样的警告提示:

    dingq@wd-u1110:~/hwsvn/2sw/1prj_linux/pdu/src/branches/pdu-isocket/isocket$ make clean;make
    rm -rf *.o tcpclient tcpserver
    gcc -g3 -Wall -o0 -std=gnu99 -c nettrans.c -o nettrans.o
    nettrans.c: In function ‘nettrans’:
    nettrans.c:59:5: warning: implicit declaration of function ‘inet_ntop’ [-Wimplicit-function-declaration]
    gcc -g3 -Wall -o0 -std=gnu99 -c tcpclient.c -o tcpclient.o
    gcc -g3 -Wall -o0 -std=gnu99 -c frm_package.c -o frm_package.o
    gcc -g3 -Wall -o0 -std=gnu99 -c sensor-att7053.c -o sensor-att7053.o
    gcc  nettrans.o tcpclient.o frm_package.o sensor-att7053.o -o tcpclient


    解决办法:

    1. -sta=gnu99的选项是后来加上去的,不加的话不能在for循环中初始化变量,比如:

    for(int i=0; i<10; i++)

    2. 添加对头文件<arpa/inet.h>的包含,编译成功,没有警告;

    dingq@wd-u1110:~/hwsvn/2sw/1prj_linux/pdu/src/branches/pdu-isocket/isocket$ make clean;make
    rm -rf *.o tcpclient tcpserver
    gcc -g3 -Wall -o0 -std=gnu99 -c nettrans.c -o nettrans.o
    gcc -g3 -Wall -o0 -std=gnu99 -c tcpclient.c -o tcpclient.o
    gcc -g3 -Wall -o0 -std=gnu99 -c frm_package.c -o frm_package.o
    gcc -g3 -Wall -o0 -std=gnu99 -c sensor-att7053.c -o sensor-att7053.o
    gcc  nettrans.o tcpclient.o frm_package.o sensor-att7053.o -o tcpclient

    问题解决。



  • 相关阅读:
    mybatis的知识点总结
    orm框架与缓存的关系
    mybatis知识点
    mybatis
    MyBatis的动态SQL详解
    工资谈判技巧
    MySQL 创建函数(Function)
    开始AFNetworking
    hdu 4778 Rabbit Kingdom(减少国家)
    设计模式:代理模式
  • 原文地址:https://www.cnblogs.com/java20130726/p/3218535.html
Copyright © 2011-2022 走看看