automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: location of .h's in library


From: Daniel Reed
Subject: Re: location of .h's in library
Date: Fri, 18 Jun 2004 15:13:55 -0400 (EDT)

On 2004-06-18T13:50-0500, David T Farning wrote:
) I am working on my first attempt at building a library in c using
) automake.  I would like the verify the location and use of the header
) files.  Could someone verify or correct my assumptions.
)
) 1. headers internal to the library should located in /src
) 2. those headers should be dependencies under _SOURCES =
) 3. follow normal header rules of one .h per .c
)
) 4. public prototypes should be located in /includes
) 5. these header will be installed in prefix/includes via
)       _include_DATA =
) 6. use very few public headers to prevent the need for library users
)       to need many #includes.

Your proposal may make sense for your particular project, but there is no
specific standard.

You should split your headers whichever way makes the most sense for your
project's API. Arbitrary rules like "one header per source file" do not get
you much (unless your code is already hopelessly disorganized).

Package-specific headers should probably installed using pkginclude_HEADERS,
which will default to /usr/local/include/PACKAGE/. This may include things
like primary interface headers (data types and function protocols) as well
as any internal headers needed for special purposes (modules, extensions,
etc.).

Artificially reducing the number of #includes is probably not worthwhile. If
it makes sense to break your public interface into several headers, go for
it. An example might be if your library has a "standard" or simple
interface, and an additional "advanced" interface that allows finer-grain
interaction. Another may be if your library has multiple uses, and it is
conceivable a developer may wish to use one portion but not the rest.

(So, don't split by source file, but do split by component or task.)

-- 
Daniel Reed <address@hidden>    http://people.redhat.com/djr/   
http://naim.n.ml.org/
"Murphy's Law is recursive. Washing your car to make it rain doesn't
work."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]