Просмотр исходного кода

refactor: 修改宏定义的方式

SongZihuan 3 лет назад
Родитель
Сommit
79522b0890

+ 6 - 45
CMakeLists.txt

@@ -81,55 +81,16 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
 set(CMAKE_MACOSX_RPATH TRUE)
 include_directories(${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR})  # 添加默认的include路径
 
-set(definitions
-    aFunVersion="${PROJECT_VERSION}"
-    aFunDescription="${PROJECT_DESCRIPTION}"
-
-    systemName="${CMAKE_SYSTEM_NAME}"
-    compilerID="${CMAKE_C_COMPILER_ID}"
-
-    aFunMajorVersion=${PROJECT_VERSION_MAJOR}
-    aFunMinorVersion=${PROJECT_VERSION_MINOR}
-    aFunPatchVersion=${PROJECT_VERSION_PATCH}
-
-    aFunSharePrefix="${CMAKE_SHARED_LIBRARY_PREFIX}"
-    aFunShareSuffix="${CMAKE_SHARED_LIBRARY_SUFFIX}"
-    aFunStaticPrefix="${CMAKE_STATIC_LIBRARY_PREFIX}"
-    aFunStaticSuffix="${CMAKE_STATIC_LIBRARY_SUFFIX}"
-    aFunExeSuffix="${CMAKE_EXECUTABLE_SUFFIX}")  # 默认的预定义宏
-
-if (WIN32 OR CYGWIN)
-    list(APPEND definitions aFunWIN32=1)
-    set(aFunWIN32 1)
-endif()
-
-if (WIN32 AND NOT CYGWIN)
-    list(APPEND definitions aFunWIN32_NO_CYGWIN=1)
-    set(aFunWIN32_NO_CYGWIN 1)
-endif()
-
-if (CYGWIN)
-    list(APPEND definitions aFunCYGWIN=1)
-    set(aFunCYGWIN 1)
-endif()
-
-if (CMAKE_BUILD_TYPE STREQUAL Debug)
-    list(APPEND definitions aFunDEBUG=1)
-    set(aFunDEBUG 1)
-endif()
-
-configure_file(${CMAKE_SOURCE_DIR}/include/base.h.in
-               ${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/aFunbase.h
-               @ONLY)
-
 add_subdirectory(deps)   # 安装依赖
 include(deps)  # 查找依赖
-if (DEPS_FOUND)
-    #include(${CMAKE_CURRENT_LIST_DIR}/lang/hgt.cmake)  # 安装lang库
-    add_subdirectory(src)
-    include(aFunHeader)
+if (NOT DEPS_FOUND)
+    return()
 endif()
 
+#include(${CMAKE_CURRENT_LIST_DIR}/lang/hgt.cmake)  # 安装lang库
+add_subdirectory(src)
+include(aFunHeader)
+
 #install(EXPORT aFunlang
 #        NAMESPACE "aFunlang::"
 #        DESTINATION ${INSTALL_CMAKEDIR}

+ 0 - 32
include/base.h.in

@@ -1,32 +0,0 @@
-/**
- * 由CMake自动生成的宏定义头文件
- */
-#ifndef AFUN_BASE_H_IN_H
-#define AFUN_BASE_H_IN_H
-
-// aFun 信息
-#define aFunVersion "@PROJECT_VERSION@"
-#define aFunDescription "@PROJECT_DESCRIPTION@"
-
-// 平台信息
-#define systemName "@CMAKE_SYSTEM_NAME@"
-#define compilerID "@CMAKE_C_COMPILER_ID@"
-
-// 版本信息
-#define aFunMajorVersion @PROJECT_VERSION_MAJOR@
-#define aFunMinorVersion @PROJECT_VERSION_MINOR@
-#define aFunPatchVersion @PROJECT_VERSION_PATCH@
-
-// 系统信息
-#define aFunSharePrefix "@CMAKE_SHARED_LIBRARY_PREFIX@"
-#define aFunShareSuffix "@CMAKE_SHARED_LIBRARY_SUFFIX@"
-#define aFunStaticPrefix "@CMAKE_STATIC_LIBRARY_PREFIX@"
-#define aFunStaticSuffix "@CMAKE_STATIC_LIBRARY_SUFFIX@"
-#define aFunExeSuffix "@CMAKE_EXECUTABLE_SUFFIX@"
-
-#cmakedefine aFunWIN32
-#cmakedefine aFunWIN32_NO_CYGWIN
-#cmakedefine aFunCYGWIN
-#cmakedefine aFunDEBUG
-
-#endif //AFUN_BASE_H_IN_H

+ 2 - 2
include/core/code.h

@@ -16,7 +16,7 @@ namespace aFuncore {
         bool writeByteCode(const aFuntool::FilePath &file_path, bool debug=false) const;  // NOLINT 允许忽略返回值
         bool readByteCode(const aFuntool::FilePath &file_path);
 
-#ifdef aFunDEBUG
+#ifdef AFUN_DEBUG
         void display() const;
 #endif
 
@@ -55,7 +55,7 @@ namespace aFuncore {
         ByteCode *read_v1(FILE *f, bool debug=false, int8_t read_type=code_element, bool to_son=false);
         [[nodiscard]] std::string getMD5_v1() const;
 
-#ifdef aFunDEBUG
+#ifdef AFUN_DEBUG
         void display() const;
 #endif
 

+ 2 - 2
include/tool/log-macro.h

@@ -27,7 +27,7 @@
 #undef aFunWriteTrack
 #define aFunIgnoreFatalError 0  /* 必须忽略FatalError */
 
-#elif defined aFunDEBUG
+#elif defined AFUN_DEBUG
 
 #ifndef aFunWriteTrack
 #define aFunWriteTrack 1  /* 是否记录Track */
@@ -94,7 +94,7 @@
 
 #endif
 
-#if defined aFunDEBUG
+#if defined AFUN_DEBUG
 #undef aFunConsoleTrack
 #define aFunConsoleTrack 1
 #elif (!aFunWriteTrack || !defined aFunConsoleTrack)

+ 6 - 6
include/tool/path.h

@@ -4,7 +4,7 @@
 #include "tool-type.h"
 
 /* 路径工具 */
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
 
 namespace aFuntool {
     AFUN_STATIC const char *SEP = "\\";
@@ -21,13 +21,13 @@ namespace aFuntool {
 #endif
 
 namespace aFuntool {
-    AFUN_STATIC const char *SHARED_PREFIX = aFunSharePrefix;
-    AFUN_STATIC const char *SHARED_SUFFIX = aFunShareSuffix;
+    AFUN_STATIC const char *SHARED_PREFIX = AFUN_SHARE_PREFIX;
+    AFUN_STATIC const char *SHARED_SUFFIX = AFUN_SHARE_SUFFIX;
 
-    AFUN_STATIC const char *STATIC_PREFIX = aFunStaticPrefix;
-    AFUN_STATIC const char *STATIC_SUFFIX = aFunStaticSuffix;
+    AFUN_STATIC const char *STATIC_PREFIX = AFUN_STATIC_PREFIX;
+    AFUN_STATIC const char *STATIC_SUFFIX = AFUN_STATIC_SUFFIX;
 
-    AFUN_STATIC const char *EXE_SUFFIX = aFunExeSuffix;
+    AFUN_STATIC const char *EXE_SUFFIX = AFUN_EXE_SUFFIX;
 }
 
 #endif //AFUN_PATH_H

+ 1 - 1
include/tool/tool-stdio.h

@@ -14,7 +14,7 @@ namespace aFuntool {
     AFUN_STATIC bool clear_stdin();
 }
 
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
 
 #ifdef _MSC_VER
 #pragma warning(disable : 5105)  // 关闭 5105 的警告输出 (Windows.h中使用)

+ 1 - 1
include/tool/tool-stdio.inline.h

@@ -14,7 +14,7 @@ namespace aFuntool {
     }
 }
 
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
 namespace aFuntool {
     int fputs_stdout(const char *str) {
         return fputs_std_(str, stdout);

+ 0 - 2
include/tool/tool-type.h

@@ -9,8 +9,6 @@
 #include <cinttypes>
 #include <cstdarg>
 #include "macro.h"
-#include "macro.h"
-#include "aFunbase.h"
 
 namespace aFuntool {
     AFUN_STATIC const char NUL = 0;

+ 7 - 0
src/CMakeLists.txt

@@ -43,6 +43,13 @@ add_subdirectory(interface)  # interface 依赖 core
 #foreach(tgt IN LISTS aFunList)
 #    target_sources(${tgt} PRIVATE ${source} ${private_h} ${include_h})
 #    target_include_directories(${tgt} PRIVATE ${PROJECT_SOURCE_DIR}/include)
+#    target_compile_definitions(${tgt}
+#            PRIVATE
+#                AFUN_VERSION="${PROJECT_VERSION}"
+#                AFUN_DESCRIPTION="${PROJECT_DESCRIPTION}"
+#                AFUN_MAJOR_VERSION=${PROJECT_VERSION_MAJOR}
+#                AFUN_MINOR_VERSION=${PROJECT_VERSION_MINOR}
+#                AFUN_PATCH_VERSION=${PROJECT_VERSION_PATCH})
 #    define_FILENAME(${tgt})
 #endforeach()
 #

+ 37 - 37
src/core/code.cpp

@@ -23,7 +23,7 @@ namespace aFuncore {
         delete code;
     }
 
-#ifdef aFunDEBUG
+#ifdef AFUN_DEBUG
     /**
      * 显式代码内容
      */
@@ -54,7 +54,7 @@ namespace aFuncore {
     }
 #endif
 
-#define Done(write) do{ \
+#define done(write) do{ \
 if(!(write)){ \
     errorLog(aFunCoreLogger, "Write/Read bytecode fail: %s [%p]", #write, f); \
     return false; \
@@ -75,7 +75,7 @@ if(!(write)){ \
 
         const Code::ByteCode *tmp = code;
         while (tmp != nullptr) {
-            Done(tmp->write_v1(f, debug));
+            done(tmp->write_v1(f, debug));
             if (tmp->type == ByteCode::code_block && tmp->data.block.son != nullptr) {
                 tmp = tmp->data.block.son;
                 continue;
@@ -84,7 +84,7 @@ if(!(write)){ \
             if (tmp->next == nullptr) {
                 do {
                     tmp = tmp->father;
-                    Done(aFuntool::byteWriteInt(f, static_cast<int8_t>(3)));
+                    done(aFuntool::byteWriteInt(f, static_cast<int8_t>(3)));
                 } while (tmp != nullptr && tmp->next == nullptr);
                 if (tmp == nullptr)
                     break;
@@ -92,7 +92,7 @@ if(!(write)){ \
             } else
                 tmp = tmp->next;
         }
-        Done(aFuntool::byteWriteInt(f, static_cast<int8_t>(0)));
+        done(aFuntool::byteWriteInt(f, static_cast<int8_t>(0)));
         return true;
     }
 
@@ -114,7 +114,7 @@ if(!(write)){ \
         const Code::ByteCode *tmp = code;
         while (tmp != nullptr) {
             int8_t type_ = aFuntool::NUL;
-            Done(aFuntool::byteReadInt(f, &type_));
+            done(aFuntool::byteReadInt(f, &type_));
             switch (type_) {
                 case 0:
                     goto RETURN;
@@ -154,7 +154,7 @@ RETURN:
         return true;
     }
 
-#undef Done
+#undef done
 
     /**
      * 计算代码的MD5值(版本:1)
@@ -200,7 +200,7 @@ RETURN:
     static const std::string ByteCodeHead = "aFunByteCode";  // NOLINT
     static const int MaxByteCodeVersion = 1;  // 字节码版本号, 有别于 aFun 版本号
 
-#define Done(write) do{ \
+#define done(write) do{ \
 if(!(write)){           \
     errorLog(aFunCoreLogger, "Write/Read bytecode file fail: %s [%p]", #write, f); \
     goto RETURN_FALSE; \
@@ -225,11 +225,11 @@ if(!(write)){           \
         } else
             debugLog(aFunCoreLogger, "Write Bytecode file %s [%p] (debug: %d)", file_path.c_str(), f, debug);
 
-        Done(aFuntool::byteWriteStr(f, ByteCodeHead));
-        Done(aFuntool::byteWriteInt(f, int16_t(MaxByteCodeVersion)));
-        Done(aFuntool::byteWriteStr(f, getMD5_v1()));
-        Done(aFuntool::byteWriteInt(f, int8_t(debug)));
-        Done(write_v1(f, debug));
+        done(aFuntool::byteWriteStr(f, ByteCodeHead));
+        done(aFuntool::byteWriteInt(f, int16_t(MaxByteCodeVersion)));
+        done(aFuntool::byteWriteStr(f, getMD5_v1()));
+        done(aFuntool::byteWriteInt(f, int8_t(debug)));
+        done(write_v1(f, debug));
         aFuntool::fileClose(f);
         debugLog(aFunCoreLogger, "Write Bytecode file success");
         return true;
@@ -259,21 +259,21 @@ RETURN_FALSE:
             debugLog(aFunCoreLogger, "Read Bytecode file %s [%p]", file_path.c_str(), f);
 
         std::string head;
-        Done(aFuntool::byteReadStr(f, head));
+        done(aFuntool::byteReadStr(f, head));
         if (head != ByteCodeHead)
             return false;
 
         int16_t version;
-        Done(aFuntool::byteReadInt(f, &version));
+        done(aFuntool::byteReadInt(f, &version));
         switch (version) {  // NOLINT 为拓展方便, 使用switch-case而不是if-else
             case 1: {
                 debugLog(aFunCoreLogger, "Read Bytecode file version 1");
                 std::string md5;
                 int8_t debug;
-                Done(aFuntool::byteReadStr(f, md5));
-                Done(aFuntool::byteReadInt(f, &debug));
+                done(aFuntool::byteReadStr(f, md5));
+                done(aFuntool::byteReadInt(f, &debug));
 
-                Done(read_v1(f, debug));
+                done(read_v1(f, debug));
                 std::string md5_ = getMD5_v1();
                 if (md5_ != md5)
                     goto RETURN_FALSE;
@@ -293,7 +293,7 @@ RETURN_FALSE:
         return false;
     }
 
-#undef Done
+#undef done
 
     /**
      * 创建 `start` 代码块
@@ -384,7 +384,7 @@ RETURN_FALSE:
         return new_code;
     }
 
-#ifdef aFunDEBUG
+#ifdef AFUN_DEBUG
     /**
      * 显式代码块内容
      */
@@ -399,7 +399,7 @@ RETURN_FALSE:
     }
 #endif
 
-#define Done(write) do{ \
+#define done(write) do{ \
 if(!(write)){           \
     errorLog(aFunCoreLogger, "Write Code::ByteCode fail: %s [%p]", #write, f); \
     return false; \
@@ -414,29 +414,29 @@ if(!(write)){           \
     bool Code::ByteCode::write_v1(FILE *f, bool debug) const{
         switch (type) {
             case code_element:
-                Done(aFuntool::byteWriteInt(f, static_cast<int8_t>(code_element)));
-                Done(aFuntool::byteWriteInt(f, static_cast<int8_t>(prefix)));
-                Done(aFuntool::byteWriteStr(f, (data.element)));
+                done(aFuntool::byteWriteInt(f, static_cast<int8_t>(code_element)));
+                done(aFuntool::byteWriteInt(f, static_cast<int8_t>(prefix)));
+                done(aFuntool::byteWriteStr(f, (data.element)));
                 break;
             case code_block:
                 if (data.block.son == nullptr)
-                    Done(aFuntool::byteWriteInt(f, static_cast<int8_t>(4)));  // 空 block 标注为 4
+                    done(aFuntool::byteWriteInt(f, static_cast<int8_t>(4)));  // 空 block 标注为 4
                 else
-                    Done(aFuntool::byteWriteInt(f, static_cast<int8_t>(code_block)));
-                Done(aFuntool::byteWriteInt(f, static_cast<int8_t>(prefix)));
-                Done(aFuntool::byteWriteInt(f, static_cast<int8_t>(data.block.block_type)));
+                    done(aFuntool::byteWriteInt(f, static_cast<int8_t>(code_block)));
+                done(aFuntool::byteWriteInt(f, static_cast<int8_t>(prefix)));
+                done(aFuntool::byteWriteInt(f, static_cast<int8_t>(data.block.block_type)));
                 break;
             default:
                 break;
 
         }
         if (debug)
-            Done(aFuntool::byteWriteInt(f, static_cast<int16_t>(line)));
+            done(aFuntool::byteWriteInt(f, static_cast<int16_t>(line)));
         return true;
     }
 
-#undef Done
-#define Done(write) do{ \
+#undef done
+#define done(write) do{ \
 if(!(write)){           \
     errorLog(aFunCoreLogger, "Read Code::ByteCode fail: %s [%p]", #write, f); \
     return nullptr;         \
@@ -456,8 +456,8 @@ if(!(write)){           \
             case code_element: {
                 int8_t prefix_ = aFuntool::NUL;
                 std::string element_;
-                Done(aFuntool::byteReadInt(f, &prefix_));
-                Done(aFuntool::byteReadStr(f, element_));
+                done(aFuntool::byteReadInt(f, &prefix_));
+                done(aFuntool::byteReadStr(f, element_));
                 ret = new Code::ByteCode(belong, element_, 0, char(prefix_));
                 break;
             }
@@ -465,8 +465,8 @@ if(!(write)){           \
             case code_block: {
                 int8_t prefix_ = aFuntool::NUL;
                 int8_t block_type = aFuntool::NUL;
-                Done(aFuntool::byteReadInt(f, &prefix_));
-                Done(aFuntool::byteReadInt(f, &block_type));
+                done(aFuntool::byteReadInt(f, &prefix_));
+                done(aFuntool::byteReadInt(f, &block_type));
                 ret = new Code::ByteCode(belong, BlockType(block_type), nullptr, 0, char(prefix_));
                 break;
             }
@@ -477,7 +477,7 @@ if(!(write)){           \
 
         if (debug) {
             int16_t line_ = aFuntool::NUL;
-            Done(aFuntool::byteReadInt(f, &line_));
+            done(aFuntool::byteReadInt(f, &line_));
             ret->line = line;
         }
 
@@ -494,7 +494,7 @@ if(!(write)){           \
         return ret;
     }
 
-#undef Done
+#undef done
 
     /**
      * 计算代码的MD5值(版本:1)

+ 1 - 1
src/main-help.cpp

@@ -10,7 +10,7 @@ void printVersion() {
 
 void printWelcomeInfo() {
     aFun::cout << "aFunlang " aFunVersion " CommandLine (" __DATE__ ", " __TIME__ ")\n";
-    aFun::cout << "[" compilerID "] on " systemName "\n";
+    aFun::cout << "[" COMPILER_ID "] on " SYSTEM_NAME "\n";
     aFun::cout << "(Enter the aFun code to run in the top activity)\n";
 }
 

+ 2 - 2
src/main.cpp

@@ -7,7 +7,7 @@ std::string program_name;
 std::string home_path;
 bool tty_stdin = false;
 
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
 
 int argc_s = 0;
 char **argv_s = nullptr;
@@ -50,7 +50,7 @@ int main(int argc, char **argv) {
     try {
         auto factor = aFun::LogFactory(home_path + aFun::SEP + "aFunlog", true);
 
-#ifdef aFunDEBUG
+#ifdef AFUN_DEBUG
         auto core_logger = aFuntool::Logger(factor, "aFun-core", aFun::log_track);
         auto sys_logger = aFuntool::Logger(factor, "aFun-sys", aFun::log_track);
         auto aFun_logger = aFuntool::Logger(factor, "aFun", aFun::log_track);

+ 28 - 2
src/tool/CMakeLists.txt

@@ -26,11 +26,37 @@ endforeach()
 add_library(tool-shared SHARED "")
 add_library(tool-static STATIC "")
 
+# 基础宏定义
+set(definitions)
+if (WIN32 OR CYGWIN)
+    list(APPEND definitions AFUN_WIN32=1)
+endif()
+if (WIN32 AND NOT CYGWIN)
+    list(APPEND definitions AFUN_WIN32_NO_CYGWIN=1)
+endif()
+if (CYGWIN)
+    list(APPEND definitions AFUN_CYGWIN=1)
+endif()
+if (CMAKE_BUILD_TYPE STREQUAL Debug)
+    list(APPEND definitions AFUN_DEBUG=1)
+endif()
+
+
 foreach(tgt tool-shared tool-static)
     target_sources(${tgt} PRIVATE ${source} ${private_h} PUBLIC ${public_h_build} ${public_h_install})
     target_include_directories(${tgt} PUBLIC ${build_include} ${install_include})
-    set_target_properties(${tgt} PROPERTIES
-                          PUBLIC_HEADER "${public_h_build}")
+    target_compile_definitions(${tgt}
+            PUBLIC
+                ${definitions}
+                SYSTEM_NAME="${CMAKE_SYSTEM_NAME}"
+                COMPILER_CXX_ID="${CMAKE_CXX_COMPILER_ID}"
+                COMPILER_C_ID="${CMAKE_C_COMPILER_ID}"
+                AFUN_SHARE_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}"
+                AFUN_SHARE_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"
+                AFUN_STATIC_PREFIX="${CMAKE_STATIC_LIBRARY_PREFIX}"
+                AFUN_STATIC_SUFFIX="${CMAKE_STATIC_LIBRARY_SUFFIX}"
+                AFUN_EXE_SUFFIX="${CMAKE_EXECUTABLE_SUFFIX}")
+    set_target_properties(${tgt} PROPERTIES PUBLIC_HEADER "${public_h_build}")
     define_FILENAME(${tgt})
 endforeach()
 

+ 3 - 3
src/tool/directory.cpp

@@ -11,7 +11,7 @@
 #include "log.h"
 #include "tool-stdio.h"
 
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
 #ifdef _MSC_VER
 #pragma warning(disable : 5105)  // 关闭 5105 的警告输出 (Windows.h中使用)
 #endif
@@ -21,7 +21,7 @@
 #endif
 
 namespace aFuntool {
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
     typedef wchar_t aFun_path;
 #else
     typedef char aFun_path;
@@ -138,7 +138,7 @@ namespace aFuntool {
      */
     std::string getExePath() {
         aFun_path exe_path[218] = {0};
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
         DWORD ret = GetModuleFileNameW(nullptr, exe_path, 217);  // 预留一位给NUL
         if (ret == 0 || wcslen(exe_path) == 0)
             return "";

+ 4 - 4
src/tool/file.cpp

@@ -2,7 +2,7 @@
 #include "file.h"
 #include "tool-stdio.h"
 
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
 #ifdef _MSC_VER
 #pragma warning(disable : 5105)  // 关闭 5105 的警告输出 (Windows.h中使用)
 #endif
@@ -20,7 +20,7 @@
 #endif
 
 namespace aFuntool {
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
     typedef struct _stat64 aFun_stat;
     typedef wchar_t aFun_path;
 #else
@@ -36,7 +36,7 @@ namespace aFuntool {
      */
     int get_stat(aFun_stat &stat_, const std::string &path_){
         int re;
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
         aFun_path *tmp = nullptr;
         if (convertWideByte(&tmp, path_.c_str(), CP_UTF8) == 0)
             return -1;
@@ -98,7 +98,7 @@ namespace aFuntool {
     FILE *fileOpen(const char *path_, const char *mode_) {
         if (strlen(mode_) >= 5)
             return nullptr;
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
         FILE *file = nullptr;
         wchar_t *path = nullptr;
         wchar_t mode[5];

+ 1 - 1
src/tool/log.cpp

@@ -24,7 +24,7 @@
 #include "str.h"
 #include "tool-exit.h"
 
-#ifdef aFunWIN32
+#ifdef AFUN_WIN32
 
 #include <Windows.h>
 

+ 1 - 1
src/tool/stdio.cpp

@@ -21,7 +21,7 @@ namespace aFuntool {
     OutStream cerr{printf_stderr};
 }
 
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
 #include <cstring>
 #include <cstdarg>
 #include <csignal>

+ 3 - 3
src/tool/string.cpp

@@ -24,7 +24,7 @@ namespace aFuntool {
         if (str != nullptr) {
             auto size = STR_LEN(str);
             char *tmp = NEW_STR(size);
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
             strcpy_s(tmp, size + 1, str);
 #else
             strcpy(tmp, str);
@@ -49,13 +49,13 @@ namespace aFuntool {
 
         auto size = STR_LEN(first) + STR_LEN(second);
         char *new_str = NEW_STR(size);
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
         strcat_s(new_str, size + 1, first);
 #else
         strcat(new_str, first);
 #endif
         if (second != nullptr) {
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
             strcat_s(new_str, size + 1, second);
 #else
             strcat(new_str, second);

+ 2 - 2
src/tool/time.cpp

@@ -34,7 +34,7 @@ namespace aFuntool {
             t = &tmp;
 
         time(t);  // 获取时间戳
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
         struct tm lt{};
         if (localtime_s(&lt, t) != 0)
             return nullptr;
@@ -63,7 +63,7 @@ namespace aFuntool {
             t = &tmp;
 
         time(t);  // 获取时间戳
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
         struct tm lt{};
         if (localtime_s(&lt, t) != 0)
             return "";

+ 1 - 1
test/src/tool-utf.cpp

@@ -5,7 +5,7 @@ using namespace aFuntool;
 int main() {
     setlocale(LC_ALL, "");
 
-#ifdef aFunWIN32_NO_CYGWIN
+#ifdef AFUN_WIN32_NO_CYGWIN
     wchar_t *tmp;
     const wchar_t *tmp2 = L"你好";
     const char *tmp3 = "你好";