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


Groups > comp.lang.c > #103764

Re: Private and public code

From GOTHIER Nathan <nathan.gothier@gmail.com>
Newsgroups comp.lang.c
Subject Re: Private and public code
Date 2017-02-12 23:06 +0100
Organization A noiseless patient Spider
Message-ID <20170212230626.6abd64ddf4cf9559744cacb8@gmail.com> (permalink)
References <20170212200353.005eb833d8a8d4e8e6d8f3de@gmail.com> <egbq9cFbmb2U3@mid.individual.net> <20170212213845.24b28c8a15ee4e41cfe2e07f@gmail.com> <o7qi67$ded$1@dont-email.me>

Show all headers | View raw


On Sun, 12 Feb 2017 20:58:27 +0000
Richard Heathfield <rjh@cpax.org.uk> wrote:

> Similarly, headers can be shared amongst source files in a module, 
> without necessarily being published as part of the binary distribution.

You can do the same with source inclusion without mixing private and public headers in the same place which bring a bit of confusion in your source tree.

Here an example of source tree I use:

/project/src     <- source files
        /include <- headers
        /bin     <- binaries
        /lib     <- libraries
        /tmp     <- object files
        /doc     <- documentation

I usually split /src with directories for each set of related functions (library) such as:

/src/set1        
    /...
    /setk

And sometimes I share code with /src/common for any set.

I also split complex functions in small functions with the rule, at most one function per source file with include gard for source inclusion if the function should not be public. At last I only compile public code.

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


Thread

Private and public code GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-12 20:03 +0100
  Re: Private and public code Ian Collins <ian-news@hotmail.com> - 2017-02-13 08:10 +1300
    Re: Private and public code GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-12 21:38 +0100
      Re: Private and public code Richard Heathfield <rjh@cpax.org.uk> - 2017-02-12 20:58 +0000
        Re: Private and public code GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-12 23:06 +0100
          Re: Private and public code Richard Heathfield <rjh@cpax.org.uk> - 2017-02-13 06:00 +0000
            Re: Private and public code GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-13 08:31 +0100
      Re: Private and public code Ian Collins <ian-news@hotmail.com> - 2017-02-13 19:07 +1300
        Re: Private and public code GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-13 09:14 +0100

csiph-web