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


Groups > comp.lang.c > #28688

Re: what is the best way

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: what is the best way
Date 2012-11-27 13:14 -0500
Organization A noiseless patient Spider
Message-ID <50B502FC.7060903@verizon.net> (permalink)
References <50b4d9fc$0$3108$ba620e4c@news.skynet.be>

Show all headers | View raw


On 11/27/2012 10:19 AM, Andre wrote:
> to organize source in a multi soucres project.
> Is a main.h file with every definition for every sources the best or
> a each.h file for each.c file the best.
> It's a verry loooong time last I used c.

There's lots of different ways to do this. My own convention has been to
create one header file for each module, which will in general contain
multiple function definitions, but usually only one with external
linkage. The header file will provide declarations for every identifier
with external linkage defined in that module. If there are no such
identifiers (this is often the case for the module which defines
main()), no header is needed. The header will also contain definitions
for every typedef and every struct, union, or enumeration needed by
those declarations. If there are any special values associated with the
arguments or return value of any of the functions it declares, it will
#define macros for those values. Every #define and type definition will
appear explicitly only in one particular header file; they will be
#included into any other header where needed.
For libraries, the headers associated with each module in the library
are used only for compiling those modules. I prepare a special header
for users of the library, declaring only those identifiers with external
linkage that users are intended to access, along with the associated
types and macros.

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