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


Groups > comp.lang.c > #94160

Re: To include or not to include

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: To include or not to include
Date 2016-09-27 12:38 -0700
Organization None to speak of
Message-ID <lnoa39rv49.fsf@kst-u.example.com> (permalink)
References (16 earlier) <nsdtc9$vpr$1@dont-email.me> <87inthbf8o.fsf@bsb.me.uk> <nse8am$auu$1@dont-email.me> <lnshslrxot.fsf@kst-u.example.com> <nseff3$7bc$1@dont-email.me>

Show all headers | View raw


BartC <bc@freeuk.com> writes:
> On 27/09/2016 19:42, Keith Thompson wrote:
>> BartC <bc@freeuk.com> writes:
>
>>>    gcc A.c X.c Y.c
>>
>> Was that intended to explain what you mean by the word "module"?
>
>
>> Let me ask directly: What exactly do you mean by the word "module"?
>
> The same as as 'module' means in any of dozens of languages.

What it means in some other languages is a language-level construct
called a "module" (or a "package"), and the details can vary from one
language to another.  C has no such language-level construct.

>> If
>> it's a synonym for "translation unit" or "source file", can you just use
>> that term instead?
>
> 'module' isn't exactly the same as those. A source file can comprise 
> other source files via include; or it can itself be part of another.

A source file is just a file.  It can contain #include directives that
tell the preprocessor to open other files when processing it, but those
other files are not part of the source file.

> While a 'translation unit' I guess is what you get after you submit a 
> top-level source file to a compiler and it does a preprocessor pass.

Syntactically, a translation-unit is defined as a sequence of zero or
more external-declarations (function-definitions or declarations).

N1570 5.1.1.1 defines the various terms (using * to denote italics,
i.e., definitions):

    A C program need not all be translated at the same time. The
    text of the program is kept in units called *source files*,
    (or *preprocessing files*) in this International Standard. A
    source file together with all the headers and source files
    included via the preprocessing directive #include is known
    as a *preprocessing translation unit*. After preprocessing,
    a preprocessing translation unit is called a *translation unit*.

> A 'module' corresponds more to an individual file as given to a 
> compiler, but also encompassing everything needed to define the module, 
> and without needing to half-compile it first.
>
> C being C, it naturally makes it hard to be more precise: three 
> source-files A, B and C, of 500 lines each, each include the same header 
> file H of 10000 lines. So most of the 'translation unit' is actually 
> common between the three.

Yes, most of the translation units derived from the source files A,
B, and C is derived from H.  (The version of H that's included might
not be the same if it depends on macros defined in A, B, and/or C.)

I'm still not at all clear what you mean by "module", or how it
differs from a translation unit.  The phrase "everything needed to
define the module" seems a bit circular.

Can you give an example of something that's a translation unit but
not a "module", or vice versa?  And if so, how is the concept of a
"module" useful?

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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


Thread

To include or not to include James Harris <james.harris.1@gmail.com> - 2016-09-23 10:45 +0100
  Re: To include or not to include David Brown <david.brown@hesbynett.no> - 2016-09-23 12:43 +0200
    Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-23 12:17 +0100
      Re: To include or not to include Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-23 13:32 +0100
        Re: To include or not to include David Brown <david.brown@hesbynett.no> - 2016-09-23 14:57 +0200
        Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-24 20:34 +0100
          Re: To include or not to include Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-24 23:55 +0100
            Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-25 01:43 +0100
              Re: To include or not to include Ian Collins <ian-news@hotmail.com> - 2016-09-25 14:38 +1300
              Re: To include or not to include Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-25 11:42 +0100
                Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-25 11:58 +0100
                Re: To include or not to include James Harris <james.harris.1@gmail.com> - 2016-09-25 14:06 +0100
                Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-25 15:15 +0100
                Re: To include or not to include Reinhardt Behm <rbehm@hushmail.com> - 2016-09-25 23:33 +0800
                Re: To include or not to include Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-09-25 10:04 -0600
                Re: To include or not to include Reinhardt Behm <rbehm@hushmail.com> - 2016-09-26 00:21 +0800
                Re: To include or not to include "James R. Kuyper" <jameskuyper@verizon.net> - 2016-09-25 13:17 -0400
                Re: To include or not to include James Harris <james.harris.1@gmail.com> - 2016-09-26 00:18 +0100
                Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-26 17:55 +0100
                Re: To include or not to include Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-26 20:07 +0100
                Re: To include or not to include supercat@casperkitty.com - 2016-09-26 12:13 -0700
                Re: To include or not to include James Harris <james.harris.1@gmail.com> - 2016-09-27 01:25 +0100
                Re: To include or not to include supercat@casperkitty.com - 2016-09-26 18:05 -0700
                Re: To include or not to include Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-27 14:27 +0100
                Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-27 14:49 +0100
                Re: To include or not to include Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-27 15:15 +0100
                Re: To include or not to include Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-09-27 07:42 -0700
                Re: To include or not to include Keith Thompson <kst-u@mib.org> - 2016-09-27 09:30 -0700
                Re: To include or not to include Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-09-27 10:06 -0700
                Re: To include or not to include supercat@casperkitty.com - 2016-09-27 08:12 -0700
                Re: To include or not to include Tim Rentsch <txr@alumni.caltech.edu> - 2016-09-28 10:46 -0700
                Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-27 17:55 +0100
                Re: To include or not to include supercat@casperkitty.com - 2016-09-27 10:19 -0700
                Re: To include or not to include Keith Thompson <kst-u@mib.org> - 2016-09-27 11:42 -0700
                Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-27 19:57 +0100
                Re: To include or not to include Keith Thompson <kst-u@mib.org> - 2016-09-27 12:38 -0700
                Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-27 21:00 +0100
                Re: To include or not to include Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-28 01:50 +0100
                Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-28 10:55 +0100
                Re: To include or not to include Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-09-27 13:33 -0700
                Re: To include or not to include Ike Naar <ike@iceland.freeshell.org> - 2016-09-28 19:13 +0000
                Re: To include or not to include supercat@casperkitty.com - 2016-09-27 12:38 -0700
                Re: To include or not to include James Harris <james.harris.1@gmail.com> - 2016-09-27 20:57 +0100
                Re: To include or not to include supercat@casperkitty.com - 2016-09-27 07:25 -0700
                Re: To include or not to include Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-28 00:28 +0100
                Re: To include or not to include supercat@casperkitty.com - 2016-09-30 07:53 -0700
                Re: To include or not to include Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-30 16:06 +0100
                Re: To include or not to include Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-27 13:53 +0100
                Re: To include or not to include James Harris <james.harris.1@gmail.com> - 2016-09-30 19:46 +0100
                Re: To include or not to include Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-30 20:27 +0100
                Re: To include or not to include Reinhardt Behm <rbehm@hushmail.com> - 2016-09-25 23:27 +0800
                Re: To include or not to include Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-25 11:38 -0400
                Re: To include or not to include Reinhardt Behm <rbehm@hushmail.com> - 2016-09-25 23:40 +0800
                Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-25 15:06 +0100
                Re: To include or not to include Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-25 11:49 -0400
                Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-25 18:05 +0100
                Re: To include or not to include Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-25 16:42 -0400
                Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-25 21:53 +0100
                Re: To include or not to include Jerry Stuckle <jstucklex@attglobal.net> - 2016-09-25 17:57 -0400
                Re: To include or not to include Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-25 21:20 +0100
                Re: To include or not to include BartC <bc@freeuk.com> - 2016-09-25 21:49 +0100
                Re: To include or not to include Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-26 00:40 +0100
      Re: To include or not to include David Brown <david.brown@hesbynett.no> - 2016-09-23 14:56 +0200
  Re: To include or not to include Richard Heathfield <rjh@cpax.org.uk> - 2016-09-23 13:31 +0100
    Re: To include or not to include James Harris <james.harris.1@gmail.com> - 2016-09-23 13:52 +0100
      Re: To include or not to include Richard Heathfield <rjh@cpax.org.uk> - 2016-09-23 14:35 +0100
    Re: To include or not to include Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-23 18:55 +0100
      Re: To include or not to include Richard Heathfield <rjh@cpax.org.uk> - 2016-09-23 20:33 +0100
  Re: To include or not to include Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-09-23 08:22 -0600
  Re: To include or not to include Richard Damon <Richard@Damon-Family.org> - 2016-09-23 11:37 -0400

csiph-web