Monday, September 28, 2015

Day 1: Crash course in C/C++ & computer architecture

Step 2: Crash course in C/C++ & computer architecture (continued)

Comments: The amount of detail in this stream is amazing and quite honestly, overwhelming. I might have to work out some sort of system to absorb the sheer amount of information.
Progress: I grokked a large portion of it.  Will review before next video. Onwards!
Notes (This isn't a log of the entire video, rather, the parts that I felt were relevant to me):

What is Linking?

  • The back half of the compilation process.
  • Gathers all references to link together to make executable
  • What is the Unresolved external error?
    • External to the compilation unit where it was being used
    • unresolved means it couldn't find an actual definition!

How does windows, the linker, and your program know where to start?

  • The predefined name  WinMain
  • Use MSDN, don't bother with memorizing

WinMain() prototype

  • Lots of Windows only stuff here.
  • LPSTR(a pointer to string), HINSTANCE (a running program) 
  • hInstance
    • it refers to ourselves!
  • hPrevInstance
    • old, not important
  • LPSTR lpCmdLine
    • what got sent to us when we were run
    • arguments and stuff from the command line
  • int nCmdShow
    • Run in normal window or minimized windows

What is that letter before Instance / PrevInstance / etc

  • This comes from Hungarian Notation (an old standard where you prefix everything you type)
  • p for pointers, l for long, h for handle, etc

What's _In_ for?

  • Tells you what direction the data in flowing
  •  __In__ means it's passing information TO Windows.
  •  You typically want to remove this before compiling / running.

Function

  • Something that holds code for us that we can reuse
  • void: does not return anything when the function is called
  • <return value, aka what comes back from function> foo (<parameters>)

What's the ; (semi-colon) for?

  • End-of-line delimiter, it defines the end of a C++ statement

What is CALLBACK for?

  • A C Macro, it expands to some special decoration this is used from Windows
  • Decoration that tells compiler and linker that it's special
  • There are constraints that needs to be met!

When we removed foo() why was is a compile error and not a linker error?

  • This happens because C/C++ are languages that do NOT allow you to use thing that have not been defined yet
  • But if you can't actually call something unless it's defined, how are there ever unresolved external symbols at link time?
    • C allows forward declaration
    • Functions are divided into declaration and definition

Tidbits from Video 1 Q&A

  • Sysinternals, if you want a tool that grabs OutputDebugString into a log?
 

No comments:

Post a Comment