Chinaunix

标题: 常用的warning [打印本页]

作者: phillipls    时间: 2008-05-17 15:18
标题: 常用的warning
    *
      warning: "/*" within comment
  举例: /************************************************/
         /*
         /*  save snmp entry data
         /*  add by Tina Lee 2003/7/11
         /*************************************************/
  说明:意思是说/* */ 中间又包含了/*
  修改:改成这样就好了
         /************************************************
          *
          *  save snmp entry data
          *  add by Tina Lee 2003/7/11
          *************************************************/   
            
         
    *
      warning: no previous prototype for
      'get_char_for_sta'
  举例:无
  说明:函数没有声明,只有定义
  修改:在相应的.h文件中添加该函数的声明。
  
  
  
    *
      warning: unused parameter 'mcb'
  举例:
        int ifnMenuQuit(MCB_T *mcb)
           {
             return QUIT;
            }  
  说明:因为函数参数中的mcb,在该函数中没有被使用,所以产生warning
  修改:对没使用的参数使用 para=para;
         int ifnMenuQuit(MCB_T *mcb)
           {
             mcb=mcb;   
   * Date: Sun, 15 Jul 2001 00:56:27 -0400
   * CC: gcc at gcc dot gnu dot org
   * References:
  > What is the rationale for this warning ? What can break or is it a
  > standards thing ?
  Imagine foo.h:
  blah blah blah
  Now bar.c:
  #include "foo.h"
  #include "grill.h"
  Now imagine a preprocessor that isn't smart enough to put
  the newline in for you...
  blah blah blah#include "grill.h"
  It may not include grill.h.
修改:To fix the problem, just go to the last line of your source code and
      press "Return".
    *
      warning: cast increases required alignment of
      target type
举例:
     #define OSPF_CRU_BMC_DWTOPDU(pu1PduAddr,u4Value) \
             *((UINT4 *)(pu1PduAddr)) = OSIX_HTONL(u4Value);
说明:这个问题比较难解决,可以不做修改,因为如果有alignment error的话会进入异常处理,
      异常处理会解决这个问题。现在修改的方法是使用memcpy,一个字节,一个字节的拷贝。不知道
      该方法是否可行。
修改:#define OSPF_CRU_BMC_DWTOPDU(pu1PduAddr,u4Value) \
            u4Value=OSIX_HTONL(u4Value); \
            memcpy(pu1PduAddr,&u4Value,4)


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/35795/showart_691770.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2