9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Alberto Cortes <alcortes@coitt.es>
To: 9fans <9fans@cse.psu.edu>
Subject: [9fans] creating a library, simple question
Date: Fri, 20 Aug 2004 12:15:29 +0200	[thread overview]
Message-ID: <20040820101529.GA15555@shire> (raw)

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


             reply	other threads:[~2004-08-20 10:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-20 10:15 Alberto Cortes [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040820101529.GA15555@shire \
    --to=alcortes@coitt.es \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).