Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #28708

Re: what is the best way

From Les Cargill <lcargill99@comcast.com>
Newsgroups comp.lang.c
Subject Re: what is the best way
Date 2012-11-27 20:06 -0600
Organization A noiseless patient Spider
Message-ID <k93rh8$3ks$1@dont-email.me> (permalink)
References <50b4d9fc$0$3108$ba620e4c@news.skynet.be> <k931s6$jk1$1@dont-email.me> <ahkk83Fn8fdU2@mid.individual.net> <k93l11$8kp$1@dont-email.me> <ahl79gFn8fdU4@mid.individual.net>

Show all headers | View raw


Ian Collins wrote:
> Les Cargill wrote:
>> Ian Collins wrote:
>>> Les Cargill wrote:
>>>>
>>>> There is no "best". Still:
>>>>
>>>> - Have one header .h per .c file.
>>>
>>> That isn't necessarily a good idea.  If a header declares the interface
>>> to a module or library, the functions declared in the header are often
>>> defined in more than one C file.
>>
>> But it's easier for me to use it to publish only stuff that's in
>> one 'C' file. I realize people do this in other ways, but I've
>> never found a case where this didn't work out...
>
> Fair enough.  I prefer more smaller C files over one bigger one, so my
> public headers tend to cover a group of files.
>


I too prefer smaller ones. Perhaps working with CASE tools that
ended evolution in UML destroyed my good sense :), but that's
how they roll - lots of small files, each with a minimum
of side effects.

In the example I gave, I don't think any of the source or
header  files were over 100 lines, blank lines and comments
included.

>> I have published libraries with *only* the constituent headers - an
>> example is a signals processing library I wrote which laid over fftw-3
>> and libsndfile. If you want the "fft" part, you include fft.h; reverse
>> fft requires rfft.h
>>
>> A library is, after all, just an archive...
>
> Take care with your terminology there, dynamic libraries are often
> different beasts from static archives.
>

I suppose... although I can easily think of a .so or .dll as
nothing more than a fancier container... YMMV.

>>> How to manage interface declarations and implementations really depends
>>> on the the complexity of the application and the environment.  In most
>>> large projects I've seen or worked on there are a mix of public and
>>> module private headers.  OS libraries are a good example of this, there
>>> will be a public header which ends up being part of the end user
>>> distribution and private headers that never leave the private source
>>> tree.
>>>
>>
>> For an O/S or compiler library, that's quite a different thing - if
>> you're building under Unix path assumptions, then you are forced to
>> at least have public headers.
>>
>> But IMO, everything in a ... non-infrastructure library
>> should be public and on the same level. And this convention
>> makes mixing 'C' and C++ much easier...
>
> I don't see why that would be the case.  C++ happily uses system C
> libraries and there's nothing to stop you witting a library with a C
> interface entirely or partially in C++.
>

I dunno - at least conceptually, it's simpler for me if I hold
to a separately compiled module being roughly a "class", where the
header is the "interface".

You don't want to overdo it, of course.

>  > plus it's much more grep-friendly.
>
> find is your friend!
>

Couldn't agree more! But it's slightly better if you don't
need to resort to it.

>> 'Course, if you're backing into somebody else's arrangement,
>> you are better off conforming...
>
> Yep.
>

--
Les Cargill

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

what is the best way Andre <pas.mois@ailleur.be> - 2012-11-27 16:19 +0100
  Re: what is the best way Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-11-27 15:35 +0000
  Re: what is the best way Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-27 08:59 -0800
  Re: what is the best way James Kuyper <jameskuyper@verizon.net> - 2012-11-27 13:14 -0500
    Re: what is the best way Ian Collins <ian-news@hotmail.com> - 2012-11-28 08:43 +1300
      Re: what is the best way James Kuyper <jameskuyper@verizon.net> - 2012-11-27 15:02 -0500
        Re: what is the best way Ian Collins <ian-news@hotmail.com> - 2012-11-28 09:29 +1300
  Re: what is the best way Les Cargill <lcargill99@comcast.com> - 2012-11-27 12:48 -0600
    Re: what is the best way Ian Collins <ian-news@hotmail.com> - 2012-11-28 08:56 +1300
      Re: what is the best way Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-11-27 22:19 +0000
        Re: what is the best way Les Cargill <lcargill99@comcast.com> - 2012-11-27 18:21 -0600
          Re: what is the best way Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-28 05:08 -0800
            Re: what is the best way Les Cargill <lcargill99@comcast.com> - 2012-11-28 12:43 -0600
      Re: what is the best way Les Cargill <lcargill99@comcast.com> - 2012-11-27 18:15 -0600
        Re: what is the best way Ian Collins <ian-news@hotmail.com> - 2012-11-28 14:21 +1300
          Re: what is the best way Les Cargill <lcargill99@comcast.com> - 2012-11-27 20:06 -0600
            Re: what is the best way Ian Collins <ian-news@hotmail.com> - 2012-11-28 15:21 +1300
              Re: what is the best way Les Cargill <lcargill99@comcast.com> - 2012-11-27 20:31 -0600
              Re: what is the best way glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-11-28 04:00 +0000
              Re: what is the best way Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-28 05:17 -0800
                Re: what is the best way Ian Collins <ian-news@hotmail.com> - 2012-11-29 08:30 +1300
                Re: what is the best way Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-29 05:47 -0800
                Re: what is the best way Ian Collins <ian-news@hotmail.com> - 2012-11-30 07:37 +1300
                Re: what is the best way Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-11-29 11:35 -0800
    Re: what is the best way Keith Thompson <kst-u@mib.org> - 2012-11-27 17:25 -0800
      Re: what is the best way Les Cargill <lcargill99@comcast.com> - 2012-11-27 20:15 -0600
      Re: what is the best way pete <pfiland@mindspring.com> - 2012-11-27 23:48 -0500
    Re: what is the best way Sergio Durigan Junior <sergiodj@riseup.net> - 2012-11-28 03:06 -0200
      Re: what is the best way pete <pfiland@mindspring.com> - 2012-11-28 01:35 -0500
  Re: what is the best way pete <pfiland@mindspring.com> - 2012-11-28 00:13 -0500

csiph-web