From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <600308d60408200823600459b5@mail.gmail.com> Date: Fri, 20 Aug 2004 17:23:57 +0200 From: Francisco Ballesteros To: Alberto Cortes , Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] creating a library, simple question In-Reply-To: <20040820101529.GA15555@shire> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <20040820101529.GA15555@shire> Cc: Topicbox-Message-UUID: d7b02040-eacd-11e9-9e20-41e7f4b1d025 just keep your tools separate in the header and add a /* internal use only */ comment to that section. You have examples in some of the libraries, see /sys/src. If the symbols are extern, nobody can prevent others from using them. hth On Fri, 20 Aug 2004 12:15:29 +0200, Alberto Cortes wrote: > i am trying to create a library, the source files looks like this: > > term% ls > me_util.c > me_util.h > mevents.c > mevents.h > mkfile > term% cat mkfile > < /$objtype/mkfile > > LIB=libmevents.a$O > > OFILES=\ > mevents.$O\ > me_util.$O\ > > HFILES=\ > mevents.h\ > me_util.h\ > > > "me_util.c" defines some helper functions for my library and... > "me_util.h" declares them. > "mevents.c" defines the functions to be served by the library. > "mevents.h" is the header file to be included by other programs, its only > declares the functions defined in "mevents.c", not the ones in "me_util.c". > > How do i prevent other programs that include "mevents.h" and are > linked to my library, from seeing the functions in "me_utils.c"? > > Additional explanation: > "me_util.c" declares a "void error(char *s)" function, but other > programs would want to use functions called "error" for sure. How do i > prevent the two "error" functions from collision? > > i have seen some libraries with the underscore solution: > > void > _error(char *s) > > is it a good solution to prevent name collision? > > -- > http://montoya.aig.uc3m.es/~acortes/index.html >