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