- 
                Notifications
    You must be signed in to change notification settings 
- Fork 14
Adds initial draft for separate compilation #96
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
          
     Open
      
      
            VictorEijkhout
  wants to merge
  27
  commits into
  cplusplus:master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
VictorEijkhout:master
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from 26 commits
      Commits
    
    
            Show all changes
          
          
            27 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      92a9a34
              
                Create separate-compilation.md
              
              
                VictorEijkhout c42254b
              
                victor first stab at separate compilation
              
              
                VictorEijkhout ba6de1b
              
                shuffling stuff around
              
              
                VictorEijkhout d84acea
              
                Update separate-compilation.md
              
              
                VictorEijkhout 45635e0
              
                Update sources/modules/compilation-model/separate-compilation.md
              
              
                VictorEijkhout 1022ea2
              
                Update sources/modules/compilation-model/separate-compilation.md
              
              
                VictorEijkhout 96bb445
              
                Update sources/modules/compilation-model/separate-compilation.md
              
              
                VictorEijkhout bf8faef
              
                Update sources/modules/compilation-model/separate-compilation.md
              
              
                VictorEijkhout 0b0d33a
              
                Update sources/modules/compilation-model/separate-compilation.md
              
              
                VictorEijkhout 25620d9
              
                Update sources/modules/compilation-model/separate-compilation.md
              
              
                VictorEijkhout 49f1a56
              
                Update sources/modules/compilation-model/separate-compilation.md
              
              
                VictorEijkhout 55ec0c2
              
                Update sources/modules/compilation-model/separate-compilation.md
              
              
                VictorEijkhout b698abe
              
                Update separate-compilation.md
              
              
                VictorEijkhout 2e82bd9
              
                Update separate-compilation.md
              
              
                VictorEijkhout 4f6a10a
              
                Update separate-compilation.md
              
              
                VictorEijkhout 5125283
              
                Update separate-compilation.md
              
              
                VictorEijkhout cea2214
              
                Update separate-compilation.md
              
              
                VictorEijkhout a303097
              
                Update separate-compilation.md
              
              
                VictorEijkhout f5f70a4
              
                Update separate-compilation.md
              
              
                VictorEijkhout 61c29b7
              
                Update separate-compilation.md
              
              
                VictorEijkhout 3a05bb1
              
                Update separate-compilation.md
              
              
                VictorEijkhout 996a433
              
                Update separate-compilation.md
              
              
                VictorEijkhout 0635d33
              
                Update separate-compilation.md
              
              
                VictorEijkhout 71a6612
              
                Update separate-compilation.md
              
              
                VictorEijkhout 7313ec4
              
                Update separate-compilation.md
              
              
                VictorEijkhout 03e04d5
              
                Merge branch 'master' into master
              
              
                vulder b51b857
              
                Update sources/modules/compilation-model/separate-compilation.md
              
              
                vulder File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
        
          
          
            109 changes: 109 additions & 0 deletions
          
          109 
        
  sources/modules/compilation-model/separate-compilation.md
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| ## 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._ | ||
|  | ||
| ------------------------------------------------------------------------ | ||
| Level Objective | ||
| ----------------- ------------------------------------------------------ | ||
| Foundational: Basic use of separate compilation | ||
|  | ||
| Main: Command of supporting mechanisms and tools | ||
|  | ||
| Advanced: Technicalities and tools | ||
|  | ||
| ------------------------------------------------------------------------ | ||
|  | ||
| ### Motivation | ||
|  | ||
| _Why is this important?_ | ||
| _Why do we want to learn/teach this topic?_ | ||
|  | ||
| This module outlines the issues involved in using separate compilation on multiple program files. | ||
|  | ||
| 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: Basic use of separate compilation | ||
|  | ||
| #### Background/Required Knowledge | ||
|  | ||
| A student: | ||
|  | ||
| 1. 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 | ||
|  | ||
| * 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._ | ||
|  | ||
| * Explain differences (including in desirability) between having explicit declarations of functions in the main program versus using header files or modules. | ||
| * Compilation on a single commandline versus using multiple commands. | ||
| * What needs to be recompiled if only a function is altered? Altered in use syntax versus altered only in semantics. | ||
|  | ||
| ### Main: Command of supporting mechanisms and tools | ||
|  | ||
| #### Background/Required Knowledge | ||
|  | ||
| * All of the above. | ||
|  | ||
| #### Student outcomes | ||
|  | ||
| A student should be able to: | ||
|  | ||
| 1. Explain what a translation unit is, and its relation to header files. | ||
| 2. Use compile flags, including `-I` and `-L` to specify search paths. | ||
| 3. Make header files for their own code, including using header guards. | ||
| 4. Use include directives for the headers of external libraries. | ||
|  | ||
| #### Caveats | ||
|  | ||
| * Build systems make things both easier and harder. | ||
| * Student does not have to set include/library paths. | ||
| * Build systems prevent unnecessary recompilation. | ||
| * Build systems have a separate learning curve. | ||
| * Build systems will pay off when using libraries, less with self-contained student code. | ||
|  | ||
| #### Points to cover | ||
|  | ||
| * Cover the mechanisms for include and library paths to your own code, as well as discovery mechanisms for external libraries. | ||
|  | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: Technicalities and tools | ||
|  | ||
| _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._ | ||
|  | ||
| * Language inter-operability: the `extern "C"` mechanism. | ||
| * Linker conventions including name mangling. | ||
|         
                  vulder marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| * The `nm` tool for inspection object files and libraries, including de-mangling. | ||
| * Understand the issues involved in deciding between include guards and `#pragma once`. | ||
|  | ||
| [1]: ../object-model/declarations.md | ||
| [2]: ../object-model/definitions.md | ||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.