* Re: Function Scope question
[not found] ` <brown.207.000A6973@falam.ch>
@ 1995-07-15 4:00 ` Jonathan Oei
0 siblings, 0 replies; only message in thread
From: Jonathan Oei @ 1995-07-15 4:00 UTC (permalink / raw)
David Claude Brown (brown@falam.ch) wrote:
> In article <3tugkj$o5r@paperboy.ids.net> joei@conan (Jonathan Oei) writes:
> [snip]
> >The question is: How can I declare f4() so that it is only
> >visible WITHIN THE LIBRARY, and that f3() and g2() are the
> >only externally visible functions?
> >I am trying this on a AlphaServer 2100 running digital UNIX 3.2
> >(used to be OSF/1), using the cc compiler.
> There is no way to do this in vanilla C. However, you can do this using
> various tricks of your local environment:
>
> Unix Lookup things about shared-libraries
>
So now I have re-phrased the question:
I am creating a shared library for use by other programmers
but only want them to be able to access certain routines.
(Sounds like a job for static/extern, but wait a sec...)
Example:
l1.c:
extern int Func1 (void) { return 1; } // public function
static int Func2 (void) { return 2; } // file scope/private
extern int Func3 (void) { return Func4() }; // public function
l2.c:
int Func4 (void) { return 4; } // public function so Func3 can see it
// create mylib.so
ld -shared -no_archive -rpath . -o libmylib.so l1.o l2.o -lc
// main program
l.c
main()
{
Func3(); // returns 4
Func4(); // also returns 4, but I want a link error here!!!
}
cc -no_archive l.c -L. -lmylib -o l
Is there any way that I can hide Func4() from the user but not from
l1.c? In other words, I am looking for 'library scope.'
I am using an Alpha 2100 running digital UNIX 3.2
Thanks
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1995-07-15 4:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <3tugkj$o5r@paperboy.ids.net>
[not found] ` <brown.207.000A6973@falam.ch>
1995-07-15 4:00 ` Function Scope question Jonathan Oei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox