Re: About libraries and headers
- From: Barry Schwarz <schwarzb@xxxxxxxxx>
- Date: Sat, 09 Apr 2005 12:15:30 -0700
On 9 Apr 2005 08:36:16 -0700, tsoukase@xxxxxxxxx wrote:
>
>Hello,
>
>two questions:
>1) Why is a library a collection of compiled source-files
>while each header-file is a single source? Would it be more
>efficient if they were both either compiled or not?
>Could a "header-library" exist?
>2) Why do libraries have extensions .a and .so and
>modules .o, which should be reserved for cc -c output?
>Would it be better: module.m, lib.sl, lib.dl or something
>alike?
>Are these forms an inheritance from C's old-time or do
>they provide a specific functionality?
>
>Evangelos Tsoukas
You are assuming that the contents of a header file are closely
related to the contents of a library. The standard header files
describe the "user interface" to the standard functions (through the
use of function prototypes or macros), declare some standard types
(like FILE and size_t using typedef or macros), and provide access to
standard features (such as errno and stdin, commonly by macros). They
do not define how the standard functions perform their respective
tasks. For those systems that provide this, the source is usually
contained in a separate set of files which the user could use to
rebuild the functions. It is these separate files, not the headers,
which are used to build the libraries.
Header files, if they are even files at all, are used by the compiler.
Library files are used by the linker.
The contents of the standard headers are defined by the standard. The
organization of library files is an implementation detail about which
the standard says only that they exist.
For all the standard headers, compiling them would not generate any
executable code. They basically consist only of declarations and
preprocessing directives, no object definitions and no function
definitions. Try compiling a source file like
/* begin of file */
#include <stdio.h>
/* end of file */
While I don't know of any implementation to do so, there is no reason
that each library could not be the result of compiling a single source
file, though obviously not a header. Most would call this an object
file since the term library is usually used to denote a collection of
object files.
<<Remove the del for email>>
.
- References:
- About libraries and headers
- From: tsoukase
- About libraries and headers
- Prev by Date: Re: RealTime System + Windows XP + C# or C
- Next by Date: Re: About libraries and headers
- Previous by thread: Re: About libraries and headers
- Next by thread: Re: About libraries and headers
- Index(es):
Relevant Pages
|
Loading