Is there a difference between a "module" and a "compilation unit" ?

C

Chris Torek

Are they different names for the same concept ?

[For clarity about the pronoun "they", I will repeat the subject
line for those whose news-delivery systems mangle it:]
Is there a difference between a "module" and a "compilation unit" ?

That depends on who does the defining, no? :)

The C standards define the term "translation unit". They do not
define either "compilation unit" or "module". Thus, this newsgroup
(comp.lang.c) cannot give you a definitive answer to the question.

In languages that actually have modules (such as Modula-2 and
Modula-3), I might claim there is a subtle difference, in that
a module may require more than one compilation step and each
such step could be termed a "unit". But you would have to define
these terms with respect to C before you could get an answer.
 
B

Bob

That depends on who does the defining, no? :)
Yes.

The C standards define the term "translation unit". They do not
define either "compilation unit" or "module". Thus, this newsgroup
(comp.lang.c) cannot give you a definitive answer to the question.

So be it: "translation unit" will be used (by me) from now on. :)

Thanks.
 
P

pete

Bob said:
So be it: "translation unit" will be used (by me) from now on. :)

A translation unit is the output of the preprocessor.
A translation unit consists of a sequence of external declarations.
 
P

Peter Nilsson

pete wrote:
-> Bob wrote:
-> > > > Is there a difference between a "module" and a
-> > > > "compilation unit" ?
-> > >
-> > > That depends on who does the defining, no? :)
-> >
-> > Yes.
-> >
-> > > The C standards define the term "translation unit". They do
-> > > not define either "compilation unit" or "module". Thus, this
-> > > newsgroup (comp.lang.c) cannot give you a definitive answer
-> > > to the question.
-> >
-> > So be it: "translation unit" will be used (by me) from now on. :)
->
-> A translation unit is the output of the preprocessor.
-> A translation unit consists of a sequence of external declarations.

Section 5 says... "An implementation translates C source files..."

"Source file" probably makes more sense than translation unit, or
preprocessing translation unit (which by definition may consist of
more than one file.)

Although programming has the concept of modules, C generally doesn't.
There is no immediate way to share objects with external linkage
exclusively within a select group of source files.
 
B

Bob

Although programming has the concept of modules, C generally doesn't.
There is no immediate way to share objects with external linkage
exclusively within a select group of source files.

Exactly. Something like what Delphi does for example, if I'm not
mistaken.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,228
Latest member
MikeMichal

Latest Threads

Top