Search code examples
csplint

Addressing splint warnings about functions "not used" while they are passed as parameters


On a program of me, the splint checker warns:

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

The start() function is used. The program uses the expat XML parser which works with callbacks. You give the parser a function:

XML_SetElementHandler(parser, start, end);

and the parser calls it back at some points. This is a very common idiom in C and I wonder why splint complains. I find nothing in the FAQ or in the manual.


Solution

  • Do you call XML_SetElementHandler() in the same translation unit (normally the .c source file) in which start() is defined? If so, the warning might be correct: Add static to the function definition and check if your application still links without errors.