代码之家  ›  专栏  ›  技术社区  ›  bortzmeyer

解决函数作为参数传递时有关“未使用”的splint警告

  •  0
  • bortzmeyer  · 技术社区  · 16 年前

    在我的一个节目中 splint 检查器警告:

    expat-test.c:23:1: Function exported but not used outside expat-test: start
      A declaration is exported, but not used outside this module. Declaration can
      use static qualifier. (Use -exportlocal to inhibit warning)
       expat-test.c:38:1: Definition of start
    

    start()函数 习惯于该程序使用 expat 使用回调的XML解析器。为解析器提供一个函数:

    XML_SetElementHandler(parser, start, end);
    

    FAQ manual .

    3 回复  |  直到 16 年前
        1
  •  2
  •   Christoph    16 年前

    你打电话吗 XML_SetElementHandler() 在同一翻译单元(通常是.c源文件)中 start() static 查看函数定义,并检查应用程序是否仍然链接无错误。

        2
  •  2
  •   Roger Lipscombe    16 年前

        3
  •  0
  •   anon    16 年前

    我倾向于将所有未导出的函数声明为静态函数。我接受过教育,目前认为这样做是一种很好的做法。(免责声明:与大多数事情一样,此“规则”也有许多例外。)

    推荐文章