Table of Contents

Linking

Notes from Linking article

Static Libraries

Includes down to the file level of granularity. (.o actually). However, can't get updated functions for printf if needed.

Dynamic Libraries

The reason that OS's include the entire dynamic library in one go is that it can reuse the shared code segment in memory (but not data/bss segment).

Some notes from C++ learnings.

class Vector {
  Vector(initializer_list<double>); //acquire memory; initialize elements
  ~Vector();                        //destroy elements (destructor)
  // ...
 
private:
  double* elem; //pointer to elements
  int sz;       // number of elements
 
}

Programming in C

int mod(int a, int b) {
    printf("%d\n",(a % b));
	return        ((a % b) + b ) % b;
}
 
#define mod2(a,b) ((a % b) + b ) % b
 
//Value will be an *unsigned* integer of value 0xFFFFFFFF
//Which is equivalent to a signed int of value -1
//But C won't tell you the type of the variable
//So you're confused until it bites you
//Like in the above macro...
//So...make sure to typecast?
#define value ((int)0-(unsigned int)1)