跳转至内容
  • A place to talk about whatever you want

    20 主题
    154 帖子
    没有新主题
  • 7 主题
    20 帖子
    SPeakS

    @dustchens 链表结构损坏, 不闭环了 (如果问题解决可以把帖子状态设置为已解决

  • 开源软件 | 开源社区 | 开源理念 | 开源与商业 | 开源可持续发展 等相关话的交流讨论
    注: 这里的"开源"是泛化的共建共享概念, 范围包含 OSI的范围、自由软件、CC等相关内容

    57 主题
    242 帖子
    sunrisepeakS

    参考: http://forum.d2learn.org/post/493

  • 47 主题
    198 帖子
    woshinideba1425W

    错误例子(我写的)

    module; #include "httplib.h" export module mcp.compat.httplib; export namespace mcp { using HttpClient = httplib::Client; using DataSink = httplib::DataSink; using Headers = httplib::Headers; using HttpRequest = httplib::Request; using HttpResponse = httplib::Response; using HttpServer = httplib::Server; #ifdef MCP_SSL using SslServer = httplib::SSLServer; #endif }

    正确例子(官方库提供的)

    module; /* * Headers */ #ifdef _WIN32 #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS #endif //_CRT_SECURE_NO_WARNINGS #ifndef _CRT_NONSTDC_NO_DEPRECATE #define _CRT_NONSTDC_NO_DEPRECATE #endif //_CRT_NONSTDC_NO_DEPRECATE #if defined(_MSC_VER) #if _MSC_VER < 1900 #error Sorry, Visual Studio versions prior to 2015 are not supported #endif #pragma comment(lib, "ws2_32.lib") #ifndef _SSIZE_T_DEFINED #define _SSIZE_T_DEFINED #endif #endif // _MSC_VER #ifndef S_ISREG #define S_ISREG(m) (((m) & S_IFREG) == S_IFREG) #endif // S_ISREG #ifndef S_ISDIR #define S_ISDIR(m) (((m) & S_IFDIR) == S_IFDIR) #endif // S_ISDIR #ifndef NOMINMAX #define NOMINMAX #endif // NOMINMAX #include <io.h> #include <winsock2.h> #include <ws2tcpip.h> #if defined(__has_include) #if __has_include(<afunix.h>) // afunix.h uses types declared in winsock2.h, so has to be included after it. #include <afunix.h> #define CPPHTTPLIB_HAVE_AFUNIX_H 1 #endif #endif #ifndef WSA_FLAG_NO_HANDLE_INHERIT #define WSA_FLAG_NO_HANDLE_INHERIT 0x80 #endif #else // not _WIN32 #include <arpa/inet.h> #if !defined(_AIX) && !defined(__MVS__) #include <ifaddrs.h> #endif #ifdef __MVS__ #include <strings.h> #ifndef NI_MAXHOST #define NI_MAXHOST 1025 #endif #endif #include <net/if.h> #include <netdb.h> #include <netinet/in.h> #ifdef __linux__ #include <resolv.h> #undef _res // Undefine _res macro to avoid conflicts with user code (#2278) #endif #include <csignal> #include <netinet/tcp.h> #include <poll.h> #include <pthread.h> #include <sys/mman.h> #include <sys/socket.h> #include <sys/un.h> #include <unistd.h> #ifndef INVALID_SOCKET #define INVALID_SOCKET (-1) #endif #endif //_WIN32 #if defined(__APPLE__) #include <TargetConditionals.h> #endif #include <algorithm> #include <array> #include <atomic> #include <cassert> #include <cctype> #include <chrono> #include <climits> #include <condition_variable> #include <cstdlib> #include <cstring> #include <errno.h> #include <exception> #include <fcntl.h> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <memory> #include <mutex> #include <random> #include <regex> #include <set> #include <sstream> #include <string> #include <sys/stat.h> #include <system_error> #include <thread> #include <unordered_map> #include <unordered_set> #include <utility> #if defined(CPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFO) || \ defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) #if TARGET_OS_MAC #include <CFNetwork/CFHost.h> #include <CoreFoundation/CoreFoundation.h> #endif #endif // CPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFO or // CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN #ifdef CPPHTTPLIB_OPENSSL_SUPPORT #ifdef _WIN32 #include <wincrypt.h> // these are defined in wincrypt.h and it breaks compilation if BoringSSL is // used #undef X509_NAME #undef X509_CERT_PAIR #undef X509_EXTENSIONS #undef PKCS7_SIGNER_INFO #ifdef _MSC_VER #pragma comment(lib, "crypt32.lib") #endif #endif // _WIN32 #if defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) #if TARGET_OS_MAC #include <Security/Security.h> #endif #endif // CPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFO #include <openssl/err.h> #include <openssl/evp.h> #include <openssl/ssl.h> #include <openssl/x509v3.h> #if defined(_WIN32) && defined(OPENSSL_USE_APPLINK) #include <openssl/applink.c> #endif #include <iostream> #include <sstream> #if defined(OPENSSL_IS_BORINGSSL) || defined(LIBRESSL_VERSION_NUMBER) #if OPENSSL_VERSION_NUMBER < 0x1010107f #error Please use OpenSSL or a current version of BoringSSL #endif #define SSL_get1_peer_certificate SSL_get_peer_certificate #elif OPENSSL_VERSION_NUMBER < 0x30000000L #error Sorry, OpenSSL versions prior to 3.0.0 are not supported #endif #endif // CPPHTTPLIB_OPENSSL_SUPPORT #ifdef CPPHTTPLIB_MBEDTLS_SUPPORT #include <mbedtls/ctr_drbg.h> #include <mbedtls/entropy.h> #include <mbedtls/error.h> #include <mbedtls/md5.h> #include <mbedtls/net_sockets.h> #include <mbedtls/oid.h> #include <mbedtls/pk.h> #include <mbedtls/sha1.h> #include <mbedtls/sha256.h> #include <mbedtls/sha512.h> #include <mbedtls/ssl.h> #include <mbedtls/x509_crt.h> #ifdef _WIN32 #include <wincrypt.h> #ifdef _MSC_VER #pragma comment(lib, "crypt32.lib") #endif #endif // _WIN32 #if defined(CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN) #if TARGET_OS_MAC #include <Security/Security.h> #endif #endif // CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN // Mbed TLS 3.x API compatibility #if MBEDTLS_VERSION_MAJOR >= 3 #define CPPHTTPLIB_MBEDTLS_V3 #endif #endif // CPPHTTPLIB_MBEDTLS_SUPPORT // Define CPPHTTPLIB_SSL_ENABLED if any SSL backend is available // This simplifies conditional compilation when adding new backends (e.g., // wolfSSL) #if defined(CPPHTTPLIB_OPENSSL_SUPPORT) || defined(CPPHTTPLIB_MBEDTLS_SUPPORT) #define CPPHTTPLIB_SSL_ENABLED #endif #ifdef CPPHTTPLIB_ZLIB_SUPPORT #include <zlib.h> #endif #ifdef CPPHTTPLIB_BROTLI_SUPPORT #include <brotli/decode.h> #include <brotli/encode.h> #endif #ifdef CPPHTTPLIB_ZSTD_SUPPORT #include <zstd.h> #endif export module httplib; export extern "C++" { #include "httplib.h" }

    当你试图将一个非模块化的第三方库(尤其是像 httplib 这种带全局状态或初始化逻辑的库)封装进模块时:

    不要尝试只导出部分类型:除非你非常确定该库没有全局初始化逻辑(Constructor static guards)。

    使用 export extern "C++":这是将传统头文件“模块化”的最标准、最稳妥做法。

    环境对齐:在 module; 之后,务必把该库依赖的所有系统宏(如 _WIN32, WIN32_LEAN_AND_MEAN 等)都写清楚。

  • 20 主题
    56 帖子
    FrozenLemonTeeF

    @SPeak 具体没研究过,不过JetBrains的IDE集成程度比vscode高,可能不太能通过命令或者修改配置文件的方式来修改。如果有朋友有相关了解的可以贴在这里。

  • 一个技术知识分享、学习、交流的社区

    15 主题
    48 帖子
    sunrisepeakS

    @johanvx 版块已创建, 可以检查确认一下是否有话题贴/Topic工具的权限

    https://forum.d2learn.org/category/21/blog-johan-xie
  • Got a question? Ask away!

    4 主题
    14 帖子
    SPeakS

    备注一下使数学公式的使用语法

    单行公式语法 - $ 你的公式 $

    $ log_2^n $

    $ log_2^n $

    多行公式语法 - $$ 你的公式 $$

    $$ log_2^n => log_2^9 = 3 , n = 9 $$

    $$
    log_2^n =>
    log_2^9 = 3, n = 9
    $$

公告栏 | Bulletin Board

欢迎加入d2learn社区 - 社区指南
Welcome to the d2learn Community - Community Guide

一个以 [知识、技术、代码、项目、想法、开源] 相关话题为主导的社区
A community focused on topics related to [knowledge, technology, code, projects, ideas, and open source].


在线用户