Addressing bus warnings about "not used" functions while they are passed as parameters
In my program, 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 an expat XML parser that works with callbacks. You give the parser a function:
XML_SetElementHandler(parser, start, end);
and the parser calls it at some points. This is a very common idiom in C and I wonder why bus is complaining. I didn't find anything in the FAQ or in the manual .
0
source to share
3 answers
The "static" keyword effectively hides the function name from other translation units (usually a C. file). The code is still there, and from this C file you can get the function address (but not from other C files). You can then pass the address to other translation units by calling functions, or by returning the address from a function, or storing it in a global variable, etc.
+2
source to share