How to get started down the path...
Max Okumoto
okumoto at ucsd.edu
Fri Feb 11 13:30:30 PST 2005
walt wrote:
On Fri, 11 Feb 2005, Max Okumoto wrote:
2.3 Write stub functions for thing you don't want to
bring in.
Great post, Max, thanks! I've seen 'stub' used often when
talking about libraries, but I've never really understood
what it means. Could you give me a concrete example of
what a stub is and why I might want to use one?
A stub function is a function with the same signature
as the 'real' function. For instance libc contains a
function called syslog(). A stub function for syslog
would take the same parameters types, and return the
same type.
int
syslog(int type, char *bufp, int len)
{
/* no code is here */
assert(0); /* please impliment me! */
return 0; /* bogus return value */
}
The reason you write stub functions is that you don't
have the code to impliment the the functionality, but
you need the function to compile the code.
This might be the case if you were moving an application
that used syslog to an embeded system, that didn't have
syslogd running nor the library function for syslog().
Max
More information about the Kernel
mailing list