-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
873 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <stdio.h> | ||
int add(int a, int b); | ||
int div(int a, int b); | ||
int mul(int a, int b); | ||
int sub(int a, int b); | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <stdio.h> | ||
#include "head.h" | ||
|
||
int main(void) | ||
{ | ||
int sum = add(2, 24); | ||
printf("sum = %d\n", sum); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "head.h" | ||
int add(int a, int b) | ||
{ | ||
int result = a + b; | ||
return result; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include"head.h" | ||
|
||
int div(int a, int b) | ||
{ | ||
int result = a / b; | ||
return result; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "head.h" | ||
int mul(int a, int b) | ||
{ | ||
int result = a * b; | ||
return result; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "head.h" | ||
int sub(int a, int b) | ||
{ | ||
int result = a - b; | ||
return result; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "head.h" | ||
int add(int a, int b) | ||
{ | ||
int result = a + b; | ||
return result; | ||
} |
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include"head.h" | ||
|
||
int div(int a, int b) | ||
{ | ||
int result = a / b; | ||
return result; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <stdio.h> | ||
int add(int a, int b); | ||
int div(int a, int b); | ||
int mul(int a, int b); | ||
int sub(int a, int b); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <stdio.h> | ||
#include "head.h" | ||
|
||
int main(void) | ||
{ | ||
int sum = add(2, 24); | ||
printf("sum = %d\n", sum); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#get all .c files | ||
SrcFiles=$(wildcard *.c) | ||
|
||
#all .c files -> .o files | ||
ObjFiles=$(patsubst %.c,%.o,$(SrcFiles)) | ||
all:app app1 | ||
# 目标文件的用法$(Var) | ||
app:$(ObjFiles) | ||
gcc -o $@ -I ./include $(ObjFiles) | ||
#模式匹配规则,$@,$<这样的变量,只能在规则中出现 | ||
app1:$(ObjFiles) | ||
gcc -o $@ -I ./include $(ObjFiles) | ||
|
||
%.o:%.c | ||
gcc -c $< -I ./include -o $@ | ||
test: | ||
@echo $(SrcFiles) | ||
@echo $(ObjFiles) | ||
.PHONY:clean all | ||
clean: | ||
-@rm -f *.o # 不显示信息 | ||
-@rm -f app app1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
app:main.c add.c sub.c div.c mul.c | ||
gcc -o app -I ./include main.c add.c sub.c div.c mul.c | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# ObjFiles 定义目标文件 | ||
ObjFiles=main.o add.o sub.o div.o mul.o | ||
# 目标文件的用法$(Var) | ||
app:$(ObjFiles) | ||
gcc -o app -I ./include main.o add.o sub.o div.o mul.o | ||
main.o:main.c | ||
gcc -c main.c -I ./include | ||
add.o:add.c | ||
gcc -c add.c -I ./include | ||
sub.o:sub.c | ||
gcc -c sub.c -I ./include | ||
mul.o:mul.c | ||
gcc -c mul.c -I ./include | ||
div.o:div.c | ||
gcc -c div.c -I ./include | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#get all .c files | ||
SrcFiles=$(wildcard *.c) | ||
|
||
#all .c files -> .o files | ||
ObjFiles=$(patsubst %.c,%.o,$(SrcFiles)) | ||
|
||
# 目标文件的用法$(Var) | ||
app:$(ObjFiles) | ||
gcc -o app -I ./include $(ObjFiles) | ||
#模式匹配规则,$@,$<这样的变量,只能在规则中出现 | ||
%.o:%.c | ||
gcc -c $< -I ./include -o $@ | ||
test: | ||
@echo $(SrcFiles) | ||
@echo $(ObjFiles) | ||
clean: | ||
-@rm -f *.o # 不显示信息 | ||
-@rm -f app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "head.h" | ||
int mul(int a, int b) | ||
{ | ||
int result = a * b; | ||
return result; | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "head.h" | ||
int sub(int a, int b) | ||
{ | ||
int result = a - b; | ||
return result; | ||
} |
Binary file not shown.
Oops, something went wrong.