Re: How to get started down the path...

看板DFBSD_kernel作者時間21年前 (2005/02/12 05:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
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
文章代碼(AID): #123IHT00 (DFBSD_kernel)
文章代碼(AID): #123IHT00 (DFBSD_kernel)