9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Francisco Ballesteros <capt.nemo@gmail.com>
To: Alberto Cortes <alcortes@coitt.es>,
	Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] creating a library, simple question
Date: Fri, 20 Aug 2004 17:23:57 +0200	[thread overview]
Message-ID: <600308d60408200823600459b5@mail.gmail.com> (raw)
In-Reply-To: <20040820101529.GA15555@shire>

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 <alcortes@coitt.es> 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\
>
> </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 15:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-20 10:15 Alberto Cortes
2004-08-20 15:23 ` Francisco Ballesteros [this message]
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=600308d60408200823600459b5@mail.gmail.com \
    --to=capt.nemo@gmail.com \
    --cc=9fans@cse.psu.edu \
    --cc=alcortes@coitt.es \
    /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).