DragonFly kernel List (threaded) for 2005-02
Re: How to get started down the path...
On Fri, 11 Feb 2005, Max Okumoto wrote:
2.3 Write stub functions for thing you don't want to
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
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().