Upload
vuongkhanh
View
224
Download
1
Embed Size (px)
Citation preview
Why 2
1 You seek performance
3
1 You seek performance
ldquozero-overhead principlerdquo
4
2 You seek to interface
directly with hardware
5
3 Thatrsquos kinda it
6
C a nice way to avoid writing assembly language directly
7
Today
Compilation Pipeline
11
Source Code Program
12
mainc prog
int a = 1 ) prog
gcc -o prog mainc 13
mainc
int a = 1 prog
) prog main2c
int b = 2
gcc -o prog mainc main2c 14
$ gcc -o prog mainc $ prog Hello World $
15
DONE
$ gcc -o prog mainc $ prog Hello World $
16
ldquoTo debug the sausage one must see how it is maderdquo
mdashSomeone probably
17
Mainjava Mainclass
( int a = 1 java Main
18
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
1 You seek performance
3
1 You seek performance
ldquozero-overhead principlerdquo
4
2 You seek to interface
directly with hardware
5
3 Thatrsquos kinda it
6
C a nice way to avoid writing assembly language directly
7
Today
Compilation Pipeline
11
Source Code Program
12
mainc prog
int a = 1 ) prog
gcc -o prog mainc 13
mainc
int a = 1 prog
) prog main2c
int b = 2
gcc -o prog mainc main2c 14
$ gcc -o prog mainc $ prog Hello World $
15
DONE
$ gcc -o prog mainc $ prog Hello World $
16
ldquoTo debug the sausage one must see how it is maderdquo
mdashSomeone probably
17
Mainjava Mainclass
( int a = 1 java Main
18
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
1 You seek performance
ldquozero-overhead principlerdquo
4
2 You seek to interface
directly with hardware
5
3 Thatrsquos kinda it
6
C a nice way to avoid writing assembly language directly
7
Today
Compilation Pipeline
11
Source Code Program
12
mainc prog
int a = 1 ) prog
gcc -o prog mainc 13
mainc
int a = 1 prog
) prog main2c
int b = 2
gcc -o prog mainc main2c 14
$ gcc -o prog mainc $ prog Hello World $
15
DONE
$ gcc -o prog mainc $ prog Hello World $
16
ldquoTo debug the sausage one must see how it is maderdquo
mdashSomeone probably
17
Mainjava Mainclass
( int a = 1 java Main
18
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
2 You seek to interface
directly with hardware
5
3 Thatrsquos kinda it
6
C a nice way to avoid writing assembly language directly
7
Today
Compilation Pipeline
11
Source Code Program
12
mainc prog
int a = 1 ) prog
gcc -o prog mainc 13
mainc
int a = 1 prog
) prog main2c
int b = 2
gcc -o prog mainc main2c 14
$ gcc -o prog mainc $ prog Hello World $
15
DONE
$ gcc -o prog mainc $ prog Hello World $
16
ldquoTo debug the sausage one must see how it is maderdquo
mdashSomeone probably
17
Mainjava Mainclass
( int a = 1 java Main
18
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
3 Thatrsquos kinda it
6
C a nice way to avoid writing assembly language directly
7
Today
Compilation Pipeline
11
Source Code Program
12
mainc prog
int a = 1 ) prog
gcc -o prog mainc 13
mainc
int a = 1 prog
) prog main2c
int b = 2
gcc -o prog mainc main2c 14
$ gcc -o prog mainc $ prog Hello World $
15
DONE
$ gcc -o prog mainc $ prog Hello World $
16
ldquoTo debug the sausage one must see how it is maderdquo
mdashSomeone probably
17
Mainjava Mainclass
( int a = 1 java Main
18
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
C a nice way to avoid writing assembly language directly
7
Today
Compilation Pipeline
11
Source Code Program
12
mainc prog
int a = 1 ) prog
gcc -o prog mainc 13
mainc
int a = 1 prog
) prog main2c
int b = 2
gcc -o prog mainc main2c 14
$ gcc -o prog mainc $ prog Hello World $
15
DONE
$ gcc -o prog mainc $ prog Hello World $
16
ldquoTo debug the sausage one must see how it is maderdquo
mdashSomeone probably
17
Mainjava Mainclass
( int a = 1 java Main
18
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Today
Compilation Pipeline
11
Source Code Program
12
mainc prog
int a = 1 ) prog
gcc -o prog mainc 13
mainc
int a = 1 prog
) prog main2c
int b = 2
gcc -o prog mainc main2c 14
$ gcc -o prog mainc $ prog Hello World $
15
DONE
$ gcc -o prog mainc $ prog Hello World $
16
ldquoTo debug the sausage one must see how it is maderdquo
mdashSomeone probably
17
Mainjava Mainclass
( int a = 1 java Main
18
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Source Code Program
12
mainc prog
int a = 1 ) prog
gcc -o prog mainc 13
mainc
int a = 1 prog
) prog main2c
int b = 2
gcc -o prog mainc main2c 14
$ gcc -o prog mainc $ prog Hello World $
15
DONE
$ gcc -o prog mainc $ prog Hello World $
16
ldquoTo debug the sausage one must see how it is maderdquo
mdashSomeone probably
17
Mainjava Mainclass
( int a = 1 java Main
18
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
mainc prog
int a = 1 ) prog
gcc -o prog mainc 13
mainc
int a = 1 prog
) prog main2c
int b = 2
gcc -o prog mainc main2c 14
$ gcc -o prog mainc $ prog Hello World $
15
DONE
$ gcc -o prog mainc $ prog Hello World $
16
ldquoTo debug the sausage one must see how it is maderdquo
mdashSomeone probably
17
Mainjava Mainclass
( int a = 1 java Main
18
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
mainc
int a = 1 prog
) prog main2c
int b = 2
gcc -o prog mainc main2c 14
$ gcc -o prog mainc $ prog Hello World $
15
DONE
$ gcc -o prog mainc $ prog Hello World $
16
ldquoTo debug the sausage one must see how it is maderdquo
mdashSomeone probably
17
Mainjava Mainclass
( int a = 1 java Main
18
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
$ gcc -o prog mainc $ prog Hello World $
15
DONE
$ gcc -o prog mainc $ prog Hello World $
16
ldquoTo debug the sausage one must see how it is maderdquo
mdashSomeone probably
17
Mainjava Mainclass
( int a = 1 java Main
18
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
DONE
$ gcc -o prog mainc $ prog Hello World $
16
ldquoTo debug the sausage one must see how it is maderdquo
mdashSomeone probably
17
Mainjava Mainclass
( int a = 1 java Main
18
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
ldquoTo debug the sausage one must see how it is maderdquo
mdashSomeone probably
17
Mainjava Mainclass
( int a = 1 java Main
18
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Mainjava Mainclass
( int a = 1 java Main
18
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Mainjava Mainclass
(
mainpyc
(
a = 1
mainpy
int a = 1 java Main
python mainpy
19
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Mainjava Mainclass
int a = 1 (
maino
)
prog
(
mainpyc
(
int a = 1
mainc
a = 1
mainpy
int a = 1 java Main
python mainpy
prog
20
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
21
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
22
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
mainc
int a = 1 ( ) int a = 1 prog
Pre-Process
Compile
Link 23
maino prog
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
mainc
int a = 1int a = 1
Pre-Process
(
main2o
(
) prog
Compile
Link 24
progmaino
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Pre-Process
Compile
Link 25
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Pre-Process
Compile
Link
26
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
include define ifdef
27
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
rimshottxt
ba-dum chh
joketxt
A man walks into a bar Ouch include rimshottxt
cpp -P joketxt 28
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
output
A man walks into a bar Ouch ba-dum chh
cpp -P joketxt 29
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
doublepy
define fosho def define kthx return define wutz print
fosho double(x) kthx x 2
wutz double(6)
These are called
ldquomacrosrdquo
cpp -P doublepy 30
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
output
def double(x) return x 2
print double(6)
cpp -P doublepy 31
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
AWESOME
output
def double(x) return x 2
print double(6)
cpp -P doublepy | python
12
cpp -P doublepy 32
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 33
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
beertxt
define beer(x) x bottles of beer on the wall
beer(99) beer(98) beer(97)
cpp -P beertxt 34
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
output
99 bottles of beer on the wall 98 bottles of beer on the wall 97 bottles of beer on the wall
cpp -P beertxt 35
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
answertxt
Whatrsquos 7 times 6 ifdef REVEAL 42 endif
cpp -P answertxt 36
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
output
Whatrsquos 7 times 6
cpp -P answertxt 37
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
output
Whatrsquos 7 times 6
cpp -P answertxt 38
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
define REVEAL
cpp -P answertxt 39
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
define REVEAL
or
cpp -P -D REVEAL answertxt
cpp -P answertxt 40
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
output
Whatrsquos 7 times 6 42
cpp -P -D REVEAL answertxt 41
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
answertxt
Whatrsquos 7 times 6 ifndef REVEAL 42 endif
cpp -P answertxt 42
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
(Fancy)
String Substitution
43
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
How is this used in C
44
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
helloc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 45
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 46
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
helloc angle brackets -gt use the system search path
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -E helloc 47
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
output
int printf(const char ) __attribute__((__format__ (__printf__ 1 2)))
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 48
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
output
int printf(const char )
int main() printf(Hello Worldn)
pretending printf is all thatrsquos defined in stdioh
gcc -E helloc 49
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
fibc
define MAX_FIB 20 int fib[MAX_FIB]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt MAX_FIB i++)
fib[i] = fib[i-1] + fib[i-2] return 0
gcc -E fibc 51
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
output
int fib[20]
int main() fib[0] = 0 fib[1] = 1 for(int i = 2 i lt 20 i++)
fib[i] = fib[i-1] + fib[i-2]
gcc -E fibc 52
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
debugc
include ltstdiohgt
int main() ifdef DEBUG
printf(Hello Worldn) endif
return 0
gcc -DDEBUG debugc -o debug 53
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
debugc
include ltstdiohgt
int main() printf(Hello Worldn) return 0
gcc -DDEBUG debugc -o debug 54
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
debugc
include ltstdiohgt
int main() return 0
gcc debugc -o debug 55
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Pre-Process
Compile
Link
56
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
int a = 1 (
maino
)
prog
int a = 1
mainc
prog
57
Compile
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Compile
Type-checking
Linear processing 58
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
def foo(a b) return a + b
foo(2 3) foo(2 3)
70
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Type-checking def vegetable(day)
if day = Tuesday return tomato
else return 1000
Python says no problem 62
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Everything has
a single fixed type
69
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
int vegetable(char day) if (strcmp(day Tuesday) = 0)
return tomato else
return 1000
65
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
int (char) if (int) return char else return int
68
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Type-checking int reptile()
return frog
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
60
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Variable Declarations int foo float foo double foo char foo
int foo[42] int foo struct Bar foo
71
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
reptilec In function lsquoreptilersquo reptilec25 warning return makes integer from pointer without a cast
int a = 4 float b = (float)a
76
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Function Declarations double fmin(double double)
return type argument types
72
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Function Declarations void exit(int)
returns nothing
int rand(void)
takes no arguments 73
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
int foo(int a int b) return a + b
74
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Compile
Type-checking
Linear processing 86
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Linear processing ( just a small note)87
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
You can only use
whatrsquos declared above
88
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
int main() printf(dn answer()) return 0
int answer() return 1337
89
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
int main() printf(dn answer()) return 0
int answer() return 1337
90
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
int answer() return 1337
int main() printf(dn answer()) return 0
91
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
int answer() declaration
int main() printf(dn answer()) return 0
int answer() definition return 1337
92
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
int answer()
int main() printf(dn answer()) return 0
declaration
int answer() return 1337
definition
95
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
int answer() declaration
include answerh
int main() printf(dn answer()) return 0
int answer() return 1337
definition
96
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Pre-Process
Compile
Link
97
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
maino
int main()
int answer()
98
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
maino
int main()
99
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
100
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
101
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 102
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
103
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo Undefined symbols for architecture x86_64
_answer referenced from _main in ccuzmRrmo
ld symbol(s) not found for architecture x86_64 collect2 ld returned 1 exit status
Linker ldquoI looked in all the object files
but I couldnrsquot find answerrdquo 104
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
maino
int main()
105
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
maino answero
int main()
int answer()
106
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
maino answero
int main()
int answer()
int main() printf(dn answer()) return 0
int answer() return 1337
107
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
maino answero
int main()
int answer()
108
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
prog
gcc -o prog mainc answerc
int main()
int answer()
109
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
110
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
answerc In function lsquomainrsquo answerc4 warning implicit declaration of function lsquoanswerrsquo
Compiler ldquoI donrsquot know what answer is
Irsquoll assume it returns an intrdquo 111
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
answerh
int answer()
include answerh
int main()
mainc
printf(dn answer()) return 0
112
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
answerh
int answer()
answerc
include answerh
int answer() return 1337
113
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Summary 114
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
answerh
int answer()
mainc
include answerh
int main() printf(dn answer()) return 0
115
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Preprocess gcc -E mainc
int answer()
int main() printf(dn answer()) return 0
116
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Compile gcc -c mainc mainc
maino
(
answero
(
117
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Link gcc -o prog maino maino
prog
(
118
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV
Pre-Process
Compile
Link 119
072SHQampRXUVHDUHKWWSRFZPLWHGX
6QWURGXFWLRQWRampDQGamp$3
)RULQIRUPDWLRQDERXWFLWLQJWKHVHPDWHULDOVRURXU7HUPVRI8VHYLVLWKWWSRFZPLWHGXWHUPV