01 - How C++ Works
01 - How C++ Works
•     solution
          –    group of projects related to each other
                 •    various project types
          –    work bench
          –    each project
                 •    group of files
                 •    complies intro a target binary
                        –    library
                        –    executable
# include <iostream>
intro
  •     direct control over hardware
  •     pass code into compiler
          –     output machine code for target-platform
                   •   instructions that cpu perform
  •     wide platform support
  •     c# of java run on a virtual machine
          –     code gets compiled into an intermediate language first
          –     buy an english book
                   •   with a translator
  •     native languages like c++
          –     translate the book in english
          –     compiler produces machine code for that target platform and architecture
          –     no translation requires
          –     just push cpu intructions into cpu
  •     from source to executable
          –     source
          –     binary executable (program of binary)
executable binaries
  •     preproccessor statements
          –   look at the file “iostream”
          –   take its contents and paste then into the file
          –   called header files
          –   iostream
                •     declaration for function cout
                        –     print stuff onto console
 •   main function
       –    called th eentry point
       –    starts executing code inside this function
       –    in the order
       –    dependent on control flow statement = calls to other functions
       –    code gets executed line by line
 •   return type for main in “int”
       –    but the main function is a special case
       –    you don’t return any kind of value from main function
               •    it will assume that you’re returning 0
               •    [only applies to main function]
 •   int main()
 •   {
       –    std::cout << “fuck my life” << std::endl;
       –    std:: cin.get();
       –    return 0;
 •   }
 •   <<-operator
       –     think of it as a function
       –     operators are functions
       –     << = print
       –     “Hello world” = parameter
       –     fuck is a paramenter
 •   push the hello string into cout
 •   push the endl
 •   std:: cin.get();
       –     waits for us to enter someting
 •   stages
 •   preproccessor gets evaluated
       –     includes contents of iostream file into this file
drop-down menus
 •   compiler transforms code into machine code
       –    solution configurations
              •    debug
              •    release
                     –    optimizatons is turned on
       –    solution platform
              •    x86
            •    win32
•   configuration
      –    properties
      –    define rules used to build certain configuration and platrofms
      –    configuratyion type
             •    type of binary created
                     –   application = executable binary
•   configuration and platform area
      –   active(debug)
      –   win32=x86
•   optimization debug vs release
•   obj file
      –     in the debug folder
•   exe file
      –     in the solution directory
               •    debug folder
•   compiler
      –   cpp files
      –   compiled individual
            •     individual obj files
         –    compiled into an object file-stitched-by linker
  •   linker
         –    takes obj files
         –    glues them
  •   compile files individually
         –    ctrl+f7
  •   build files into the debug folder
         –    obj
         –    pdb
  •   if building the entire project
         –    transforms into exe
  •   declarations
         –   statements that say that smth exists
  •   definition
         –   this is what it is
         –   the body of a functions
  •   [how does the compiler knows we have the right file]
  •   linker
         –   find the definition of that log function
         –   wires it to the Log function in the main file
         –   alternatively there is a [linker error]
                •    function’s signature details
                       –     calling convention
                                •    "void **__cdecl** Log(char const *)"
                                       –    parameter: const char pointer
                       –     actual ID
                                •    (?Log@@YAXPBD@Z) referenced in function _main
                •    unresolved external symbol called log
                       –     return value
                                •    void
                       –     these parameter
                                •    char const *
                       –     referenced in main
         –   linker unable to resolve a signal
["void __cdecl Log(char const *)"(?Log@@YAXPBD@Z) referenced in function _main]
  •   debug
        –   2 obj files
  •   common binary
–   debug
      •   exe