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


Groups > comp.lang.c > #43455

Re: Meta-C question about header order

From Jens Schweikhardt <usenet@schweikhardt.net>
Newsgroups comp.lang.c
Subject Re: Meta-C question about header order
Date 2014-04-23 19:47 +0000
Message-ID <brqjm9Fa4lcU2@mid.individual.net> (permalink)
References <bqtj0hF60hpU1@mid.individual.net> <kfnbnvxlo8w.fsf@x-alumni2.alumni.caltech.edu> <JLv4v.45915$S85.11888@en-nntp-16.dc1.easynews.com>

Show all headers | View raw


Richard Damon <Richard@damon-family.org> wrote
	in <JLv4v.45915$S85.11888@en-nntp-16.dc1.easynews.com>:
# On 4/19/14, 4:25 AM, Tim Rentsch wrote:
#> Jens Schweikhardt <usenet@schweikhardt.net> writes:
# I have been reading the many comments in this thread with some
#> interest.  Reading through your responses, I have come up with
#> this summary of motivations for using this approach (these are
#> my paraphrasings, often not quotes of the originals):
#> 
#>   + no lint warnings about repeated headers
# 
#>   + no need for include guards
# 
#>   + doxygen dependency graph much simpler
# I am not sure I would call a "flat" graph simpler. It obscures the
# difference between what you actually reference and what has been pulled
# in due to implementation detail of something you reference.

You can't see this in a graph of 20 nodes with 40 edges either.
I understand the graph with a root and 20 leaves.

#>   + no cycles in include graph
# Neither method will generated cycles. What becomes a "cycle" in nested
# includes becomes a broken topographical order (a.h must be before b.h,
# but b.h also must be before a.h)

The cycles I mean a closed loops of edges via one or more nodes.

#>   + removing unneeded includes is easier
# I disagree here, with headers include what they need, you need to only
# look at one file to see what is needed, so if you make a change, you
# have less to look at to see what is no longer needed. With all
# dependencies, both direct and indirect, expressed in the .c file, to
# identify that a header is no longer needed you need to look at every
# header file included after it to confirm. Also, if you make a change in
# a header, you need to know every client for that header, to know where
# you need to make the changes.

Well, I use a tool (Gimpel FlexeLint) to tell me which headers are
not needed. That is at least simple for me. However, FlexeLint can
tell this only for a C file, not for headers.

#>   + simpler compiler diagnostics
# Yes, you get simpler diagnostics, but a lot more of them (or a lot more
# work to avoid them). If headers include what they need, you don't need
# to look at the include trace, if foo.h has a error because it is missing
# a dependency, it doesn't matter how it got included, it needs to resolve
# it, once. In the .c includes everything case, every file that included
# that header will need to have the needed dependency fixed.
# 
#>   + easier to generate dependency makefile
# Yes, if you are manually generating makefiles.
# 
#>   + improved identifiability of refactoring opportunities
# I disagree. Since you have lost all the real dependency information, you
# have lost the hints that help you see the refactoring.

See my answer to Tim Rentsch for details of what I expect to find and how.

...
# Ultimately, it is the programmer putting effort in to make the computer
# jobs easier. The biggest advantage it gains is that for a naive
# compiler, that doesn't recognize include guards, it will reparse
# multiply included files (looking for the #endif). This can be fixed in
# the most used headers by making the include itself conditional testing
# the include guard.

Which nobody does. Having the include guard *in* the included header
instead of some intelligence in the preprocessor is the ugly kluge.
Have you ever seen

    #ifndef PROJECT_TYPES_H
    #include "project_types.h"
    #endif
    ...repeat for N other headers...

out in the wild? I haven't. So the common wisdom accepts endless
rereading and retokenization of the same headers in the header djungle.
I question the status quo in search of a paradigm shift. Big words :-)

# The main purpose we use computers is that they can do work much faster
# than us, and there job is to take away the mechanical operations so we
# can focus on the creative. This "rule" puts back on the programmer a lot
# of mechanical operations that belong really to the computer.

I believe this burden is quite lightweight. You get the header sequence
right once, that's basically it. I provide a reference in a dummy C file
including all headers with an empty main()). Look up where your header
appears in the reference sequence--no more guessing or compiler errors.

Regards,

	Jens
-- 
Jens Schweikhardt http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)

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


Thread

Meta-C question about header order Jens Schweikhardt <usenet@schweikhardt.net> - 2014-04-12 19:37 +0000
  Re: Meta-C question about header order Keith Thompson <kst-u@mib.org> - 2014-04-12 13:51 -0700
    Re: Meta-C question about header order glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-13 00:11 +0000
    Re: Meta-C question about header order Jens Schweikhardt <usenet@schweikhardt.net> - 2014-04-13 11:40 +0000
      Re: Meta-C question about header order "BartC" <bc@freeuk.com> - 2014-04-13 13:10 +0100
      Re: Meta-C question about header order Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-13 06:29 -0700
      Re: Meta-C question about header order Kaz Kylheku <kaz@kylheku.com> - 2014-04-13 14:41 +0000
    Re: Meta-C question about header order Ken Brody <kenbrody@spamcop.net> - 2014-04-15 10:36 -0400
  Re: Meta-C question about header order Richard Damon <Richard@Damon-Family.org> - 2014-04-12 16:58 -0400
    Re: Meta-C question about header order Kaz Kylheku <kaz@kylheku.com> - 2014-04-13 03:40 +0000
      Re: Meta-C question about header order Ian Collins <ian-news@hotmail.com> - 2014-04-13 16:26 +1200
        Re: Meta-C question about header order Kaz Kylheku <kaz@kylheku.com> - 2014-04-13 05:02 +0000
          Re: Meta-C question about header order Ian Collins <ian-news@hotmail.com> - 2014-04-13 17:21 +1200
            Re: Meta-C question about header order Ken Brody <kenbrody@spamcop.net> - 2014-04-15 10:59 -0400
            Re: Meta-C question about header order Ken Brody <kenbrody@spamcop.net> - 2014-04-15 11:02 -0400
          Re: Meta-C question about header order Ken Brody <kenbrody@spamcop.net> - 2014-04-15 10:59 -0400
            Re: Meta-C question about header order Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-15 08:26 -0700
            Re: Meta-C question about header order Kaz Kylheku <kaz@kylheku.com> - 2014-04-15 15:56 +0000
      Re: Meta-C question about header order Jens Schweikhardt <usenet@schweikhardt.net> - 2014-04-13 11:34 +0000
      Re: Meta-C question about header order Richard Damon <Richard@Damon-Family.org> - 2014-04-13 15:04 -0400
      Re: Meta-C question about header order Ken Brody <kenbrody@spamcop.net> - 2014-04-15 10:52 -0400
  Re: Meta-C question about header order Ian Collins <ian-news@hotmail.com> - 2014-04-13 11:09 +1200
    Re: Meta-C question about header order Jens Schweikhardt <usenet@schweikhardt.net> - 2014-04-13 11:47 +0000
      Re: Meta-C question about header order Ian Collins <ian-news@hotmail.com> - 2014-04-14 08:54 +1200
        Re: Meta-C question about header order Kaz Kylheku <kaz@kylheku.com> - 2014-04-13 21:37 +0000
          Re: Meta-C question about header order Ian Collins <ian-news@hotmail.com> - 2014-04-14 09:49 +1200
        Re: Meta-C question about header order Jens Schweikhardt <usenet@schweikhardt.net> - 2014-04-14 19:17 +0000
          Re: Meta-C question about header order Ian Collins <ian-news@hotmail.com> - 2014-04-15 10:24 +1200
            Re: Meta-C question about header order Jens Schweikhardt <usenet@schweikhardt.net> - 2014-04-16 19:58 +0000
          Re: Meta-C question about header order Richard Damon <Richard@Damon-Family.org> - 2014-04-14 21:45 -0400
  Re: Meta-C question about header order luser- -droog <luser.droog@gmail.com> - 2014-04-12 16:48 -0700
    Re: Meta-C question about header order Jens Schweikhardt <usenet@schweikhardt.net> - 2014-04-13 11:52 +0000
  Re: Meta-C question about header order Kaz Kylheku <kaz@kylheku.com> - 2014-04-13 01:04 +0000
  Re: Meta-C question about header order "BartC" <bc@freeuk.com> - 2014-04-13 10:15 +0100
    Re: Meta-C question about header order Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-13 04:06 -0700
    Re: Meta-C question about header order Jens Schweikhardt <usenet@schweikhardt.net> - 2014-04-13 12:01 +0000
      Re: Meta-C question about header order "BartC" <bc@freeuk.com> - 2014-04-13 13:46 +0100
        Re: Meta-C question about header order Jens Schweikhardt <usenet@schweikhardt.net> - 2014-04-13 13:58 +0000
  Re: Meta-C question about header order Jens Schweikhardt <usenet@schweikhardt.net> - 2014-04-13 11:29 +0000
    Re: Meta-C question about header order Martin Shobe <martin.shobe@yahoo.com> - 2014-04-13 08:48 -0500
      Re: Meta-C question about header order Jens Schweikhardt <usenet@schweikhardt.net> - 2014-04-13 14:25 +0000
        Re: Meta-C question about header order Kaz Kylheku <kaz@kylheku.com> - 2014-04-13 15:02 +0000
        Re: Meta-C question about header order Martin Shobe <martin.shobe@yahoo.com> - 2014-04-13 21:45 -0500
          Re: Meta-C question about header order Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-14 01:16 -0700
            Re: Meta-C question about header order "BartC" <bc@freeuk.com> - 2014-04-14 10:16 +0100
            Re: Meta-C question about header order Richard Damon <Richard@Damon-Family.org> - 2014-04-14 21:33 -0400
          Re: Meta-C question about header order Kaz Kylheku <kaz@kylheku.com> - 2014-04-14 16:25 +0000
            Re: Meta-C question about header order Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-14 09:47 -0700
            Re: Meta-C question about header order Martin Shobe <martin.shobe@yahoo.com> - 2014-04-14 13:29 -0500
              Re: Meta-C question about header order Kaz Kylheku <kaz@kylheku.com> - 2014-04-14 19:31 +0000
                Re: Meta-C question about header order Les Cargill <lcargill99@comcast.com> - 2014-04-14 20:03 -0500
                Re: Meta-C question about header order Kaz Kylheku <kaz@kylheku.com> - 2014-04-15 01:04 +0000
              Re: Meta-C question about header order Keith Thompson <kst-u@mib.org> - 2014-04-14 15:15 -0700
            Re: Meta-C question about header order Richard Damon <Richard@Damon-Family.org> - 2014-04-14 22:01 -0400
            Re: Meta-C question about header order "BartC" <bc@freeuk.com> - 2014-04-15 09:51 +0100
              Re: Meta-C question about header order Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-15 06:01 -0700
                Re: Meta-C question about header order "BartC" <bc@freeuk.com> - 2014-04-15 14:29 +0100
                Re: Meta-C question about header order Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-15 10:38 -0700
                Re: Meta-C question about header order Kaz Kylheku <kaz@kylheku.com> - 2014-04-15 18:27 +0000
                Re: Meta-C question about header order Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-15 12:45 -0700
                Re: Meta-C question about header order ralph <nt_consulting@yahoo.com> - 2014-04-15 22:02 -0500
          Re: Meta-C question about header order Jens Schweikhardt <usenet@schweikhardt.net> - 2014-04-14 17:44 +0000
  Re: Meta-C question about header order Tim Rentsch <txr@alumni.caltech.edu> - 2014-04-19 01:25 -0700
    Re: Meta-C question about header order Richard Damon <Richard@Damon-Family.org> - 2014-04-19 10:30 -0400
      Re: Meta-C question about header order Jens Schweikhardt <usenet@schweikhardt.net> - 2014-04-23 19:47 +0000
        Re: Meta-C question about header order James Kuyper <jameskuyper@verizon.net> - 2014-04-23 15:53 -0400
      Re: Meta-C question about header order Tim Rentsch <txr@alumni.caltech.edu> - 2014-06-10 09:25 -0700
    Re: Meta-C question about header order Jens Schweikhardt <usenet@schweikhardt.net> - 2014-04-23 19:27 +0000
      Re: Meta-C question about header order Tim Rentsch <txr@alumni.caltech.edu> - 2014-06-10 09:40 -0700

csiph-web