16 Matching Annotations
  1. Sep 2018
    1. Ok

      inline is reserve.dont do this urself, let compiler. if func in fil1.c and called in file2.c compiler cant inline it. put in header file. include it. you can include .c files. if you include jpeg preprocessor will stall. loading ts the process of taking program ..? .dll files. static is oldschool. gcc has static switch BUT IT DOESNT WORK IT DOES IT DYNAMIC ANYWAY. root of polymorphic.

    2. defined

      ifndef headername

      this doesnt include variables. they wull be taken twice anyway.

    3. Make static whenever

      unless called from somewhere else. if you want to do this, put declaration in header file. would be nice if you could see header comments in std lib but do that for your own files. extern func decla type declar. -Wmissing prototypes - encourages the compiler to tell you if youve written a func without declaran

    4. Avoid global variables

      no reason in C to use a global var. global func names, yes, global var, no. lazy and doesnt want to pass something as a parameter. global variables are a tool for the weakminded. -Wl modifies warning message behaviour on part of linker. warn me about common or weak global symbols.

    5. global

      gcc does that for you. main has to be global so OS can be called. assembler directives. .global main

    6. Variables

      defines lf2 only. any var that you declare in file, linker cant see, compiler cant see, vars in file scope. static therefore local. extern doesnt define anything. defined somehwere else. no default - diff with func. if no declaration, compiler makes one up. but for var, they have to be declared before they are used period. simply an error. no one is going to make 1 up for you.

    7. static void f(void) {

      defines local symbol f. local to file. without static, g is strong. 3rd line declares but doesnt defifne. right way to do things in c : 1. when you write func implemn/defn, you have 2 choices, you want func glbal enuf. if not global, local then declare fucn declare and declare it as static.

      1. funcs should be static in filewhenever possible.

      you can get away without using header files but you should not do that. every func declaration should be included in header file for a global. implicit func declar. if global func, pople sized, it should have declration in header file but trouble is that lang doesnt require it. cpp requries it therefore its not an extension of c but a diff language. make fucnkign header files. if header files, how does compiler look at functions calls. it looks for dunc declares. you cant overload func names, there is one or none. paramenter list in defn and declare. checks #para and types are compatible. what if compiler doesnt find declaration for func, it makes one up. and assumes return type int always. jeez. cimpiler leaves note for linker, relocation tag, this has to be mapped toa call. that can break down at link time if implicit declareation that compiler made up doesnt match the linker's?. never ignore implicit func declaration warning. PAY ATTENTION TO THESE. main is entry point. lol recursive main?! system calls main. have main call main.

    8. nt y;

      two weak x's. no type info in assembly code. you mght get info about width. linker will keep the x it saw first. but in file two we needed a double, now it will use int. in assembly addl is going to store x worth 4 bytes when we needed 8bytes. spooky! DONT DUPLICATE GLOBAL NAMES.

    9. int x;

      picks one x. in multipled files, refs to x will be mapped to same variable.

    10. nt x; p1() {}

      x weak. contrived examples. two p1() strong globals.

    11. can be

      will be

    12. int e=7;

      FUNC DEFN VS DECLARE int e=7 is defn of e int y is declaration. a defn is a declartion that provides body of func as well strong globals and weak gloals. y is weak.

    13. Rules

      scots are responsible for golf, bagpipes and pussy??

      any name defined by global is strong if init. e is strong. ep is string. x is strong, y is weak.

    14. Relocation Info (

      linker is getting this machine code. by the time you geto this level, nothing tells you waht the highlevel lang was. linker rules doesnt have much to do with compiler rules. all the linker gets is machine code. compiler or high level lang decides what the machine code looks like. assembler rules are quirky. pretty much becayse when you go to implement linker, you are not consttrained by higher level lang.

    15. e8 fc ff ff ff

      linker sees these relocations/ at offset 4 from the begin, we need R_ related to s ymbol a. the addr where that begins is actually 4. the addr will be something else but the offset wont change. coz relative.

  2. Aug 2018