Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please merge: separate compilation #96

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Changes from 12 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
92a9a34
Create separate-compilation.md
VictorEijkhout Jul 26, 2024
c42254b
victor first stab at separate compilation
VictorEijkhout Aug 29, 2024
ba6de1b
shuffling stuff around
VictorEijkhout Aug 30, 2024
d84acea
Update separate-compilation.md
VictorEijkhout Sep 26, 2024
45635e0
Update sources/modules/compilation-model/separate-compilation.md
VictorEijkhout Oct 4, 2024
1022ea2
Update sources/modules/compilation-model/separate-compilation.md
VictorEijkhout Oct 4, 2024
96bb445
Update sources/modules/compilation-model/separate-compilation.md
VictorEijkhout Oct 4, 2024
bf8faef
Update sources/modules/compilation-model/separate-compilation.md
VictorEijkhout Oct 4, 2024
0b0d33a
Update sources/modules/compilation-model/separate-compilation.md
VictorEijkhout Oct 4, 2024
25620d9
Update sources/modules/compilation-model/separate-compilation.md
VictorEijkhout Oct 4, 2024
49f1a56
Update sources/modules/compilation-model/separate-compilation.md
VictorEijkhout Oct 4, 2024
55ec0c2
Update sources/modules/compilation-model/separate-compilation.md
VictorEijkhout Oct 4, 2024
b698abe
Update separate-compilation.md
VictorEijkhout Oct 31, 2024
2e82bd9
Update separate-compilation.md
VictorEijkhout Oct 31, 2024
4f6a10a
Update separate-compilation.md
VictorEijkhout Oct 31, 2024
5125283
Update separate-compilation.md
VictorEijkhout Oct 31, 2024
cea2214
Update separate-compilation.md
VictorEijkhout Oct 31, 2024
a303097
Update separate-compilation.md
VictorEijkhout Oct 31, 2024
f5f70a4
Update separate-compilation.md
VictorEijkhout Oct 31, 2024
61c29b7
Update separate-compilation.md
VictorEijkhout Oct 31, 2024
3a05bb1
Update separate-compilation.md
VictorEijkhout Oct 31, 2024
996a433
Update separate-compilation.md
VictorEijkhout Oct 31, 2024
0635d33
Update separate-compilation.md
VictorEijkhout Oct 31, 2024
71a6612
Update separate-compilation.md
VictorEijkhout Oct 31, 2024
7313ec4
Update separate-compilation.md
VictorEijkhout Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions sources/modules/compilation-model/separate-compilation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
## C++ compilation model: Separate Compilation {#separate-comp}

_Skeleton descriptions are typeset in italic text,_
_so please don't remove these descriptions when editing the topic._

### Overview

_Provides a short natural language abstract of the module’s contents._
_Specifies the different levels of teaching._

This module outlines the issues involved in using separate compilation on multiple program files.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This module outlines the issues involved in using separate compilation on multiple program files.
This module outlines the issues involved in using separate compilation on multiple program files.

The overview normally does not contain pretext only the table with the different levels, maybe you could merge this text with the 'Motivation' below.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would merge if I could. Gimme a hint where to do that?i in my fork? elsewhere?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was resolved in today's meeting.

------------------------------------------------------------------------
Level Objective
----------------- ------------------------------------------------------
Foundational: Awareness of the existence of separate compilation
VictorEijkhout marked this conversation as resolved.
Show resolved Hide resolved

Main: Awareness of supporting mechanisms and tools

Advanced: Awareness of technicalities and tools

------------------------------------------------------------------------

### Motivation

_Why is this important?_
_Why do we want to learn/teach this topic?_

Any non-trivial program will span more than one source file. This makes separate compilation necessary. Separate compilation also leads to quick build times in projects under development.

### Topic introduction

_Very brief introduction to the topic._

### Foundational: Using
VictorEijkhout marked this conversation as resolved.
Show resolved Hide resolved

#### Background/Required Knowledge

A student:

1. needs to have the text editor skills to split a single-file program into multiple files.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need to spell that out 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't hurt to spell it out.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it actually does: a) this needs is not really related to C++ and b) if we want to consistently specify student requirements with that granularity we need to add many other skills, too that all are not really related to C++.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with removing it. Go ahead and suggest it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was resolved in today's meeting.

2. needs to be able to split function and classes into their declaration and definition. [[C++ object model: declarations]][1] [[C++ object model: Definitions]][2]


#### Student outcomes

_A list of things "a student should be able to" after the curriculum._
_The next word should be an action word and testable in an exam._
_Max 5 items._

A student should be able to:

1. split a single file program into main, one or more auxiliaries, and header files (or modules), all in one directory
2. compile and link a program that is spread over multiple files (again, all in one directory), either on the commandline or with a build system.
3. describe the functions of the various files involved: source, object, executable.


#### Points to cover
VictorEijkhout marked this conversation as resolved.
Show resolved Hide resolved

* Necessity of having function be declared at the locus of use
* Solving this by explicit declaration or by using header files.

#### Caveats

_This section mentions subtle points to understand, like anything resulting in
implementation-defined, unspecified, or undefined behavior._

1. Explain differences (including in desirability) between having explicit declarations of functions in the main program versus using header files or modules.
2. Compilation on a single commandline versus multiple. Resolution order when linking.
VictorEijkhout marked this conversation as resolved.
Show resolved Hide resolved
3. What needs to be recompiled if only a function is altered? Altered in use syntax versus altered only in semantics.
VictorEijkhout marked this conversation as resolved.
Show resolved Hide resolved

### Main: implementing
VictorEijkhout marked this conversation as resolved.
Show resolved Hide resolved

#### Background/Required Knowledge

* All of the above.

#### Student outcomes

A student should be able to:

1. Use compile flags, including `-I` and `-L` to specify search paths.
2. Make header files for their own code, including using header guards.
VictorEijkhout marked this conversation as resolved.
Show resolved Hide resolved
3. Use include directives for the headers of external libraries.
4. Be able to declare `extern` variables.
VictorEijkhout marked this conversation as resolved.
Show resolved Hide resolved

#### Caveats

1. Build systems make things both easier and harder.
VictorEijkhout marked this conversation as resolved.
Show resolved Hide resolved

#### Points to cover

* Cover the mechanisms for include and library paths to your own code, as well as discovery mechanisms for external libraries.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From reading the ASBATs, we probably need more points to cover that contain the skills necessary to reach the ASBAT level.

### Advanced
VictorEijkhout marked this conversation as resolved.
Show resolved Hide resolved

_These are important topics that are not expected to be covered but provide
guidance where one can continue to investigate this topic in more depth._

1. Language inter-operability: the `extern "C"` mechanism.
2. Linker conventions including name mangling.
3. The `nm` tool for inspection object files and libraries, including de-mangling.
4. Understand the issues involved in deciding between include guards and `#pragma once`.
VictorEijkhout marked this conversation as resolved.
Show resolved Hide resolved
VictorEijkhout marked this conversation as resolved.
Show resolved Hide resolved

[1]: ../object-model/declarations.md
[2]: ../object-model/definitions.md
Loading