From 3d07326a12136a6c248da125d230b20498937572 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Wed, 4 May 2022 22:44:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BA=86=E4=BE=8B=E5=AD=90?= =?UTF-8?q?=EF=BC=8C=E5=BC=80=E5=A7=8B=E6=AD=A3=E5=BC=8F=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=20=E9=87=8D=E6=96=B0=E8=AE=BE=E8=AE=A1=E7=9A=84=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 6 ++---- include/bus.h | 22 ++++++++++++++++++++++ include/example.h | 11 ----------- include/rail.h | 32 ++++++++++++++++++++++++++++++++ lib/CMakeLists.txt | 5 ----- lib/example.c | 14 -------------- main.c | 9 ++------- src/bus.c | 1 + src/rail.c | 1 + 9 files changed, 60 insertions(+), 41 deletions(-) create mode 100644 include/bus.h delete mode 100644 include/example.h create mode 100644 include/rail.h delete mode 100644 lib/CMakeLists.txt delete mode 100644 lib/example.c create mode 100644 src/bus.c create mode 100644 src/rail.c diff --git a/CMakeLists.txt b/CMakeLists.txt index cb62f35..a22c791 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,9 +12,7 @@ include_directories( ${PROJECT_SOURCE_DIR}/include/ ) -add_subdirectory(lib) +aux_source_directory(./src SRC) # 产生可执行文件 -add_executable(bus main.c) - -target_link_libraries(bus bus_lib) \ No newline at end of file +add_executable(bus main.c ${SRC}) \ No newline at end of file diff --git a/include/bus.h b/include/bus.h new file mode 100644 index 0000000..431b541 --- /dev/null +++ b/include/bus.h @@ -0,0 +1,22 @@ +#ifndef AUTO_PILOT_BUS_BUS_H +#define AUTO_PILOT_BUS_BUS_H + +#include "rail.h" + +struct { + /** + * 指向站点的指针 + */ + rail_node_t* rail_node_pos; + /** + * 当前行进的距离 + */ + int distance; +} bus; + +/** + * 表示公交车的结构体 + */ +typedef struct bus bus_t; + +#endif //AUTO_PILOT_BUS_BUS_H diff --git a/include/example.h b/include/example.h deleted file mode 100644 index 2a6d781..0000000 --- a/include/example.h +++ /dev/null @@ -1,11 +0,0 @@ -// -// Created by ricardo on 2022/4/29. -// - -#ifndef AUTO_PILOT_BUS_EXAMPLE_H -#define AUTO_PILOT_BUS_EXAMPLE_H - -#include "stdio.h" - -void print(char* str); -#endif //AUTO_PILOT_BUS_EXAMPLE_H diff --git a/include/rail.h b/include/rail.h new file mode 100644 index 0000000..d49e0a6 --- /dev/null +++ b/include/rail.h @@ -0,0 +1,32 @@ +#ifndef AUTO_PILOT_BUS_RAIL_H +#define AUTO_PILOT_BUS_RAIL_H + +struct { + /** + * 站点的编号 + */ + int id; + /** + * 距离上一个站点的距离 + */ + int last_node_distance; + /** + * 距离下一个站点的距离 + */ + int next_node_distance; + /** + * 指向上一个站点的指针 + */ + struct rail_node* last_node; + /** + * 指向下一个站点的指针 + */ + struct rail_node* next_node; +} rail_node; + +/** + * 表示轨道上的一个站点的结构体 + */ +typedef struct rail_node rail_node_t; + +#endif //AUTO_PILOT_BUS_RAIL_H diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt deleted file mode 100644 index 26097d7..0000000 --- a/lib/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -aux_source_directory(. LIB_SRCS) - -include_directories(../include) - -add_library(bus_lib ${LIB_SRCS}) \ No newline at end of file diff --git a/lib/example.c b/lib/example.c deleted file mode 100644 index 54f8b65..0000000 --- a/lib/example.c +++ /dev/null @@ -1,14 +0,0 @@ -// -// Created by ricardo on 2022/4/29. -// -#include "example.h" - -/** - * @brief 在stdin打印一个字符串 - * - * @param str 指向需要打印的字符串指针 - */ -void print(char* str) -{ - printf("%s", str); -} \ No newline at end of file diff --git a/main.c b/main.c index dc1bddf..0c598dd 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -#include "example.h" +#include "stdio.h" /** * @brief 程序的主函数 @@ -7,11 +7,6 @@ */ int main() { - /** - * @brief 需要输出的字符串 - * - */ - char* string = "Good morning!\n"; - print(string); + printf("同志们加油啊,不然要寄啦!\n"); return 0; } \ No newline at end of file diff --git a/src/bus.c b/src/bus.c new file mode 100644 index 0000000..f47b66b --- /dev/null +++ b/src/bus.c @@ -0,0 +1 @@ +#include "bus.h" \ No newline at end of file diff --git a/src/rail.c b/src/rail.c new file mode 100644 index 0000000..025011d --- /dev/null +++ b/src/rail.c @@ -0,0 +1 @@ +#include "rail.h" \ No newline at end of file