Skip to content

Commit 557e9c7

Browse files
committed
rename some header
1 parent e307c55 commit 557e9c7

File tree

18 files changed

+80
-16
lines changed

18 files changed

+80
-16
lines changed

c/cmkls.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#cmake最小版本需求
2+
cmake_minimum_required(VERSION xxx)
3+
4+
#设置此项目的名称
5+
project(xxx)
6+
7+
#生成可执行文件target ,后面填写的是生成此可执行文件所依赖的源文件列表。
8+
add_executable(target target_source_codes)
9+
10+
# 设置一个名字var_name 的变量,同时给此变量赋值为var_value
11+
SET(var_name var_value)
12+
13+
# 指定编译器
14+
# CMAKE_C_FLAGS_DEBUG ---- C 编译器
15+
# CMAKE_CXX_FLAGS_DEBUG ---- C++ 编译器
16+
# -std=c++11 使用 C++11
17+
# -g:只是编译器,在编译的时候,产生调试信息。
18+
# -Wall:生成所有警告信息。一下是具体的选项,可以单独使用
19+
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -wall ")
20+
21+
#指定编译类型,debug 或者为 release
22+
# debug 会生成相关调试信息,可以使用 GDB 进行
23+
# release 不会生成调试信息。当无法进行调试时查看此处是否设置为 debug.
24+
set(CMAKE_BUILD_TYPE Debug)
25+
26+
# 打印消息
27+
MESSAGE("MSG")
28+
29+
#给变量var_name赋值为var_value,comment是此变量的注释,和SET 有类似的功效,用于给某变量设置默认值
30+
option(var_name "comment" var_value)
31+
32+
# 添加include路径,也就是头文件路径
33+
include_directories(xxx)
34+
35+
# 调用xxx子目录的CMakeLists.txt执行
36+
add_subdirectory(xxx)
37+
38+
# 给编译器添加xxx参数
39+
add_compile_options(xxx)
40+
41+
# 给编译器添加库目录,
42+
link_directories(xxx)
43+
44+
# 生成库文件,SHARED代表动态库,STATIC代表静态库, 最后一个参数代表此库的源文件列表
45+
add_library(lib_name SHARED or STATIC lib_source_code)
46+
47+
# 给目标添加依赖库
48+
target_link_libraries(target_name lib_name ...)
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
#ifndef _fd_h
2+
#define _fd_h
13
#include <stdio.h>
24
#include <unistd.h>
35
#include <sys/types.h>
46
#include <sys/stat.h>
57
#include <fcntl.h>
6-
8+
#endif

c/fd/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "../include/head.h"
1+
#include "../include/fd.h"
22
int main(){
33
char *path="file.txt";
44
int fd;
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#ifndef _fileio_h
2+
#define _fileio_h
13
#include <stdio.h>
24
#include <stdlib.h>
35
int r();
46
int w();
5-
7+
#endif

c/fileio/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "../include/head.h"
1+
#include "../include/fileio.h"
22
int main(){
33
w("file.txt","this_is_an_apple");
44
r("file.txt");

c/fileio/src/r.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "../include/head.h"
1+
#include "../include/fileio.h"
22
int r(const char* filename){
33
FILE *fp = fopen("file.txt","r");
44
int i;

c/fileio/src/w.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "../include/head.h"
1+
#include "../include/fileio.h"
22
int w(const char* filename,const char* string){
33
FILE *fp;
44
fp = fopen(filename,"w");
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
#ifndef _linktable_h
2+
#define _linktable_h
13
#include <stdio.h>
24
#include <stdlib.h>
35
struct head_link;
46
struct body_link;
7+
#endif

c/link_table/src/main.c renamed to c/link_table/src/linktable.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "../include/head.h"
1+
#include "../include/linktable.h"
22

3-
*head_link hcreate() {
3+
*head_link hcreate() {
44
struct head_link *temp;
55
temp = (struct head_link*)(malloc(sizeof(struct head_link)));
66
temp->head = (struct body_link*)(malloc(sizeof(struct body_link)));

c/link_test/include/head.h

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)