Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!brl-tgr!gwyn From: gwyn@brl-tgr.ARPA (Doug Gwyn ) Newsgroups: net.lang.c Subject: Re: Variables Message-ID: <5762@brl-tgr.ARPA> Date: Wed, 14-Nov-84 00:55:57 EST Article-I.D.: brl-tgr.5762 Posted: Wed Nov 14 00:55:57 1984 Date-Received: Thu, 15-Nov-84 02:50:38 EST References: <4583@ukc.UUCP> Organization: Ballistic Research Lab Lines: 17 > I am trying to write a set of functions and procedures in C which will be used > as a set of library routines. But I can not find any way to make the variables > used inside these routines unavailable to the applications program. This is what file "static" is for. C provides only two levels of externs: globally known ("extern", default) and private to source file ("static"). Unfortunately if you have several files in your library that you want to share external data/functions without making them visible to user programs, C has not provided any mechanism for that. Two solutions are to bundle all the related sources together in a single file (with the drawback that a reference to any entry point will pull the whole object file into your binary image), or to invent names for inter-file use that the user is not likely to use in his code (e.g., _Q8Q_myfunc() ). If you have "C with classes" or C++, that provides a superior information- hiding mechanism. However, you still have to contend with the two-level global label scheme that the loader employs.