9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] creating a library, simple question
@ 2004-08-20 10:15 Alberto Cortes
  2004-08-20 15:23 ` Francisco Ballesteros
  2004-08-20 16:10 ` Charles Forsyth
  0 siblings, 2 replies; 5+ messages in thread
From: Alberto Cortes @ 2004-08-20 10:15 UTC (permalink / raw)
  To: 9fans

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\

</sys/src/cmd/mklib


"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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-08-20 18:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-20 10:15 [9fans] creating a library, simple question Alberto Cortes
2004-08-20 15:23 ` Francisco Ballesteros
2004-08-20 16:10 ` Charles Forsyth
2004-08-20 17:20   ` Alberto Cortes
2004-08-20 18:43     ` boyd, rounin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).