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


Groups > comp.lang.c > #63515

Re: Merging .h and .c source files

From Richard Heathfield <rjh@cpax.org.uk>
Newsgroups comp.lang.c
Subject Re: Merging .h and .c source files
Date 2015-06-18 15:29 +0100
Organization go, ion artisan!
Message-ID <mlukib$p4b$1@dont-email.me> (permalink)
References <b459569c-a34c-4b4b-b9eb-49f9a9ea7a4d@googlegroups.com> <mlt054$fh8$1@dont-email.me> <mlujb5$je2$1@speranza.aioe.org>

Show all headers | View raw


On 18/06/15 15:07, Morten W. Petersen wrote:
> On 18.06.2015 01:35, Richard Heathfield wrote:
>> On 18/06/15 00:27, David Kleinecke wrote:
>>> Why would anybody want to merge, say, foo.h and foo.c into a
>>> single file?
>>
>> Perhaps they would wish to do so because they haven't understood the
>> difference between the two. A source (or multiple sources) and header,
>> between them, form a module. The header contains the details of the
>> interface, and the source(s) contain(s) the implementation.
>>
>>> It's a matter of making the source code readable. It is awkward
>>> to have to always continually look at foo.h when you are reading
>>> foo.c.
>>
>> gvim foo.c
>> :sp foo.h
>>
>> Job done.
>>
>>> I usually paste foo.h into foo.c (making it, probably,
>>> uncompilable) to make foo.c readable.
>>
>> Yes, you could do that - or you could learn how to use a multi-window
>> editor such as, well, almost all of them really. What are you using to
>> read source - Notepad?
>
> Or use emacs.  I think emacs works on Mac OS X as well as Linux and
> on Windows through Cygwin or as a Windows program.

A few years ago, someone told this group about a company that was 
distributing a "vim reference t-shirt" with lots of handy commands 
printed *upside-down* on the front of the shirt (pull the shirt out and 
forward a bit, and then look down to look up). Ben Pfaff responded by 
asking whether they also did a reference tent, for emacs users.

> If you run emacs, press Ctrl-x 2, it splits into two screens.  You
> can then press Ctrl-x 3 in one of those screens, and it will split
> the other way.

The vim equivalents are :sp or :vsp

> Although maybe the need to split a screen is a sign that something
> is wrong, either being stressed out and tired or that whatever
> you're doing is too complicated.

I disagree. It can be quite handy to see a header and a source at the 
same time. It can even be quite handy to split a C file, so that one 
window shows the function and the other window shows where you're 
constructing a call to that function. (I do that a lot.)

> Something along the lines of
> that if a C function goes beyond the bottom of the editor window
> vertically means one should consider if it should be refactored.

I keep hearing that, and I do see the point, but in practice I don't 
have a problem with /long/ functions. For me, the limit is not the 
physical number of lines but the complexity of the function. Obviously 
to some extent they are related, but I wouldn't split a function up 
*only* because it happened to spill over the size of the editor window. 
(I might split it up for other reasons, though.)

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

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


Thread

Merging .h and .c source files David Kleinecke <dkleinecke@gmail.com> - 2015-06-17 16:27 -0700
  Re: Merging .h and .c source files Richard Heathfield <rjh@cpax.org.uk> - 2015-06-18 00:35 +0100
    Re: Merging .h and .c source files Reinhardt Behm <rbehm@hushmail.com> - 2015-06-18 12:51 +0800
      Re: Merging .h and .c source files Michael Sorn <invalid@example.com> - 2015-06-18 13:27 +0000
        Re: Merging .h and .c source files David Brown <david.brown@hesbynett.no> - 2015-06-18 15:38 +0200
        Re: Merging .h and .c source files gazelle@shell.xmission.com (Kenny McCormack) - 2015-06-18 13:42 +0000
        Re: Merging .h and .c source files Reinhardt Behm <rbehm@hushmail.com> - 2015-06-18 22:47 +0800
    Re: Merging .h and .c source files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-06-18 06:21 -0700
    Re: Merging .h and .c source files "Morten W. Petersen" <morphex@gmail.com> - 2015-06-18 16:07 +0200
      Re: Merging .h and .c source files Richard Heathfield <rjh@cpax.org.uk> - 2015-06-18 15:29 +0100
        Re: Merging .h and .c source files "Morten W. Petersen" <morphex@gmail.com> - 2015-06-18 16:48 +0200
          Re: Merging .h and .c source files raltbos@xs4all.nl (Richard Bos) - 2015-06-18 21:52 +0000
            Re: Merging .h and .c source files "Morten W. Petersen" <morphex@gmail.com> - 2015-06-19 03:57 +0200
              Re: Merging .h and .c source files raltbos@xs4all.nl (Richard Bos) - 2015-06-19 10:02 +0000
                Re: Merging .h and .c source files Richard Heathfield <rjh@cpax.org.uk> - 2015-06-19 11:24 +0100
                Re: Merging .h and .c source files Bartc <bc@freeuk.com> - 2015-06-19 12:10 +0100
                Re: Merging .h and .c source files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-19 13:24 +0100
                Re: Merging .h and .c source files Bartc <bc@freeuk.com> - 2015-06-19 14:09 +0100
                Re: Merging .h and .c source files "Morten W. Petersen" <morphex@gmail.com> - 2015-06-19 15:30 +0200
                Re: Merging .h and .c source files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-19 17:34 +0100
                Re: Merging .h and .c source files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-19 17:06 +0100
                Re: Merging .h and .c source files David Kleinecke <dkleinecke@gmail.com> - 2015-06-19 09:40 -0700
                Re: Merging .h and .c source files Bartc <bc@freeuk.com> - 2015-06-19 18:12 +0100
                Re: Merging .h and .c source files Keith Thompson <kst-u@mib.org> - 2015-06-19 11:25 -0700
                Re: Merging .h and .c source files David Kleinecke <dkleinecke@gmail.com> - 2015-06-20 07:31 -0700
                Re: Merging .h and .c source files glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-06-20 17:07 +0000
                Re: Merging .h and .c source files "Charles Richmond" <numerist@aquaporin4.com> - 2015-06-23 17:44 -0500
                Re: Merging .h and .c source files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-24 01:48 +0100
                Re: Merging .h and .c source files Keith Thompson <kst-u@mib.org> - 2015-06-20 12:37 -0700
                Re: Merging .h and .c source files Robert Wessel <robertwessel2@yahoo.com> - 2015-06-19 22:04 -0500
                Re: Merging .h and .c source files Les Cargill <lcargill99@comcast.com> - 2015-06-19 22:36 -0500
                Re: Merging .h and .c source files Robert Wessel <robertwessel2@yahoo.com> - 2015-06-20 01:23 -0500
                Re: Merging .h and .c source files Bartc <bc@freeuk.com> - 2015-06-19 17:54 +0100
                Re: Merging .h and .c source files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-19 19:45 +0100
                Re: Merging .h and .c source files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-06-21 07:19 -0700
                Re: Merging .h and .c source files Ian Collins <ian-news@hotmail.com> - 2015-06-20 08:52 +1200
                Re: Merging .h and .c source files Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-10 18:44 -0700
        Re: Merging .h and .c source files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-06-18 08:26 -0700
          Re: Merging .h and .c source files Richard Heathfield <rjh@cpax.org.uk> - 2015-06-18 16:41 +0100
            Re: Merging .h and .c source files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-18 17:13 +0100
              Re: Merging .h and .c source files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-06-18 09:26 -0700
                Re: Merging .h and .c source files Richard Heathfield <rjh@cpax.org.uk> - 2015-06-18 18:03 +0100
                Re: Merging .h and .c source files Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-10 18:33 -0700
                Re: Merging .h and .c source files Keith Thompson <kst-u@mib.org> - 2015-06-18 10:28 -0700
                Re: Merging .h and .c source files gazelle@shell.xmission.com (Kenny McCormack) - 2015-06-18 17:28 +0000
                Re: Merging .h and .c source files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-18 21:07 +0100
                Re: Merging .h and .c source files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-06-18 15:04 -0700
                Re: Merging .h and .c source files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-19 00:38 +0100
                Re: Merging .h and .c source files Bartc <bc@freeuk.com> - 2015-06-19 01:00 +0100
                Re: Merging .h and .c source files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-06-19 00:10 -0700
                Re: Merging .h and .c source files mark.bluemel@gmail.com - 2015-06-19 00:56 -0700
                Re: Merging .h and .c source files Richard Heathfield <rjh@cpax.org.uk> - 2015-06-19 09:18 +0100
                Re: Merging .h and .c source files John Bode <jfbode1029@gmail.com> - 2015-06-24 08:43 -0700
                Re: Merging .h and .c source files Keith Thompson <kst-u@mib.org> - 2015-06-24 11:15 -0700
                Re: Merging .h and .c source files Richard Heathfield <rjh@cpax.org.uk> - 2015-06-24 19:23 +0100
                Re: Merging .h and .c source files James Kuyper <jameskuyper@verizon.net> - 2015-06-24 14:40 -0400
                Re: Merging .h and .c source files Richard Heathfield <rjh@cpax.org.uk> - 2015-06-24 19:45 +0100
              Re: Merging .h and .c source files Keith Thompson <kst-u@mib.org> - 2015-06-18 10:19 -0700
                Re: Merging .h and .c source files gwowen <gwowen@gmail.com> - 2015-06-19 05:29 -0700
                Re: Merging .h and .c source files Keith Thompson <kst-u@mib.org> - 2015-06-19 08:26 -0700
            Re: Merging .h and .c source files "Morten W. Petersen" <morphex@gmail.com> - 2015-06-19 04:08 +0200
            Re: Merging .h and .c source files Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-10 17:53 -0700
              Re: Merging .h and .c source files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-07-10 18:40 -0700
                Re: Merging .h and .c source files Udyant Wig <udyantw@gmail.com> - 2015-07-11 10:19 +0530
                Re: Merging .h and .c source files Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-11 15:59 -0700
                Re: Merging .h and .c source files raltbos@xs4all.nl (Richard Bos) - 2015-07-13 18:50 +0000
                Re: Merging .h and .c source files Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-15 08:37 -0700
                Re: Merging .h and .c source files raltbos@xs4all.nl (Richard Bos) - 2015-07-19 21:30 +0000
                Re: Merging .h and .c source files Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-20 09:46 -0700
                Re: Merging .h and .c source files Richard Damon <Richard@Damon-Family.org> - 2015-07-11 20:08 -0400
                Re: Merging .h and .c source files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-07-11 18:26 -0700
                Re: Merging .h and .c source files Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-15 08:38 -0700
                Re: Merging .h and .c source files Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-11 15:57 -0700
                Re: Merging .h and .c source files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-07-11 16:30 -0700
                Re: Merging .h and .c source files Ian Collins <ian-news@hotmail.com> - 2015-07-12 15:51 +1200
                Re: Merging .h and .c source files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-07-12 06:03 -0700
                Re: Merging .h and .c source files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-12 21:36 +0100
                Re: Merging .h and .c source files gazelle@shell.xmission.com (Kenny McCormack) - 2015-07-12 21:27 +0000
                Re: Merging .h and .c source files Ian Collins <ian-news@hotmail.com> - 2015-07-13 10:00 +1200
                Re: Merging .h and .c source files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-07-13 04:16 -0700
                Re: Merging .h and .c source files Bartc <bc@freeuk.com> - 2015-07-13 12:47 +0100
                Re: Merging .h and .c source files Ian Collins <ian-news@hotmail.com> - 2015-07-14 08:32 +1200
                Re: Merging .h and .c source files Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-15 11:33 -0700
                Re: Merging .h and .c source files Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-15 11:24 -0700
                Re: Merging .h and .c source files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-07-15 12:29 -0700
                Re: Merging .h and .c source files Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-20 09:50 -0700
                Re: Merging .h and .c source files raltbos@xs4all.nl (Richard Bos) - 2015-07-13 18:52 +0000
                Re: Merging .h and .c source files Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-15 08:52 -0700
                Re: Merging .h and .c source files David Kleinecke <dkleinecke@gmail.com> - 2015-07-15 20:33 -0700
                Re: Merging .h and .c source files Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-20 09:53 -0700
        Re: Merging .h and .c source files Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-10 17:47 -0700
    Re: Merging .h and .c source files David Kleinecke <dkleinecke@gmail.com> - 2015-06-18 11:18 -0700
      Re: Merging .h and .c source files David Kleinecke <dkleinecke@gmail.com> - 2015-06-18 11:34 -0700
        Re: Merging .h and .c source files Morris Dovey <mrdovey@iedu.com> - 2015-06-18 15:59 -0500
      Re: Merging .h and .c source files Philipp Klaus Krause <pkk@spth.de> - 2015-06-19 12:46 +0200
    Re: Merging .h and .c source files Bartc <bc@freeuk.com> - 2015-06-18 19:23 +0100
  Re: Merging .h and .c source files Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2015-06-18 07:48 -0600
  Re: Merging .h and .c source files Bartc <bc@freeuk.com> - 2015-06-18 18:27 +0100

csiph-web