File tree Expand file tree Collapse file tree 18 files changed +80
-16
lines changed Expand file tree Collapse file tree 18 files changed +80
-16
lines changed Original file line number Diff line number Diff line change 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 ...)
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1- #include "../include/head .h"
1+ #include "../include/fd .h"
22int main (){
33 char * path = "file.txt" ;
44 int fd ;
Original file line number Diff line number Diff line change 1+ #ifndef _fileio_h
2+ #define _fileio_h
13#include <stdio.h>
24#include <stdlib.h>
35int r ();
46int w ();
5-
7+ #endif
Original file line number Diff line number Diff line change 1- #include "../include/head .h"
1+ #include "../include/fileio .h"
22int main (){
33 w ("file.txt" ,"this_is_an_apple" );
44 r ("file.txt" );
Original file line number Diff line number Diff line change 1- #include "../include/head .h"
1+ #include "../include/fileio .h"
22int r (const char * filename ){
33 FILE * fp = fopen ("file.txt" ,"r" );
44 int i ;
Original file line number Diff line number Diff line change 1- #include "../include/head .h"
1+ #include "../include/fileio .h"
22int w (const char * filename ,const char * string ){
33 FILE * fp ;
44 fp = fopen (filename ,"w" );
Original file line number Diff line number Diff line change 1+ #ifndef _linktable_h
2+ #define _linktable_h
13#include <stdio.h>
24#include <stdlib.h>
35struct head_link ;
46struct body_link ;
7+ #endif
Original file line number Diff line number Diff line change 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 )));
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments