From 1e7ce33752924349cb3edcd0b19d039a6a1b9aca Mon Sep 17 00:00:00 2001 From: yonglin_zhang <1248825327@qq.com> Date: Thu, 15 Jul 2021 21:48:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91debug=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yonglin_zhang/C/dep/CMakeLists.txt | 1 + yonglin_zhang/C/dep/alg_debug.c | 22 +++++++++++++++ yonglin_zhang/C/dep/alg_debug.h | 28 ++++++++++++++++++++ yonglin_zhang/C/link_list/src/CMakeLists.txt | 9 +++++++ 4 files changed, 60 insertions(+) create mode 100644 yonglin_zhang/C/dep/alg_debug.c create mode 100644 yonglin_zhang/C/dep/alg_debug.h diff --git a/yonglin_zhang/C/dep/CMakeLists.txt b/yonglin_zhang/C/dep/CMakeLists.txt index e69de29..77efc20 100644 --- a/yonglin_zhang/C/dep/CMakeLists.txt +++ b/yonglin_zhang/C/dep/CMakeLists.txt @@ -0,0 +1 @@ +add_library(alg_debg SHARED alg_debug.c) \ No newline at end of file diff --git a/yonglin_zhang/C/dep/alg_debug.c b/yonglin_zhang/C/dep/alg_debug.c new file mode 100644 index 0000000..4c19d13 --- /dev/null +++ b/yonglin_zhang/C/dep/alg_debug.c @@ -0,0 +1,22 @@ +#include +#include +#include "alg_debug.h" + +static char debug_path[256] = { 0 }; + +void set_debug_info_path(char *path) +{ + memcpy(debug_path, path, strlen(path)); +} + +void debug_infpo(char *info) +{ + FILE *debug = NULL; + char filename[270] = { 0 }; + + sprintf(filename, "%s/debug.txt", debug_path); + + debug = fopen(filename, "a"); + fprintf(debug, "%s", info); + fclose(debug); +} \ No newline at end of file diff --git a/yonglin_zhang/C/dep/alg_debug.h b/yonglin_zhang/C/dep/alg_debug.h new file mode 100644 index 0000000..1be7e78 --- /dev/null +++ b/yonglin_zhang/C/dep/alg_debug.h @@ -0,0 +1,28 @@ +/** + * \file alg_debug.h + * + * \brief debug信息功能 + */ + +#ifndef ALG_DEBUG_H +#define ALG_DEBUG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef DEBUG +#define ALG_DEBUG(X) debug_info(X) +#else +#define ALG_DEBUG(X) +#endif + +void set_debug_info_path(char *path); + +void debug_info(char *info); + +#ifdef __cplusplus +} +#endif + +#endif /* ALG_DEBUG_H */ diff --git a/yonglin_zhang/C/link_list/src/CMakeLists.txt b/yonglin_zhang/C/link_list/src/CMakeLists.txt index 018b8dc..3a44a51 100644 --- a/yonglin_zhang/C/link_list/src/CMakeLists.txt +++ b/yonglin_zhang/C/link_list/src/CMakeLists.txt @@ -10,7 +10,16 @@ set(INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../include" "${CMAKE_CURRENT_SOURCE_DIR}/../../dep" ) +#[[ +set(DEP_LIB_DIR + "${CMAKE_CURRENT_SOURCE_DIR}/../../dep" +) +set(DEP_LIBS + alg_debug +) +#]] include_directories(${INCLUDE_DIRS}) +#link_directories(${DEP_LIBS}) add_library(link_list SHARED ${LIB_SOURCES}) -- Gitee