{"id":67764,"date":"2026-01-29T06:17:09","date_gmt":"2026-01-28T22:17:09","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/67764.html"},"modified":"2026-01-29T06:17:09","modified_gmt":"2026-01-28T22:17:09","slug":"c%e9%ab%98%e6%95%88%e6%97%a5%e5%bf%97%e4%b8%8e%e5%91%bd%e4%bb%a4%e8%a1%8c%e8%a7%a3%e6%9e%90%e5%ae%9e%e6%88%98","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/67764.html","title":{"rendered":"C++\u9ad8\u6548\u65e5\u5fd7\u4e0e\u547d\u4ee4\u884c\u89e3\u6790\u5b9e\u6218"},"content":{"rendered":"<p>\u597d\u7684&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u5173\u4e8e\u5982\u4f55\u5728 C&#043;&#043; \u9879\u76ee\u4e2d\u7ed3\u5408\u4f7f\u7528 gflags \u8fdb\u884c\u547d\u4ee4\u884c\u53c2\u6570\u89e3\u6790\u548c spdlog \u5b9e\u73b0\u9ad8\u6027\u80fd\u65e5\u5fd7\u8bb0\u5f55\u7684\u5b9e\u6218\u6307\u5357\u3002<\/p>\n<p>\u76ee\u6807&#xff1a; \u8ba9\u7a0b\u5e8f\u80fd\u591f\u65b9\u4fbf\u5730\u901a\u8fc7\u547d\u4ee4\u884c\u914d\u7f6e\u53c2\u6570&#xff0c;\u5e76\u5c06\u8fd0\u884c\u4fe1\u606f\u9ad8\u6548\u3001\u7075\u6d3b\u5730\u8bb0\u5f55\u5230\u65e5\u5fd7\u4e2d\u3002<\/p>\n<p>\u6838\u5fc3\u7ec4\u4ef6&#xff1a;<\/p>\n<li>gflags: Google \u7684\u547d\u4ee4\u884c\u6807\u5fd7\u5e93&#xff0c;\u7528\u4e8e\u89e3\u6790\u548c\u5b58\u50a8\u547d\u4ee4\u884c\u53c2\u6570\u3002<\/li>\n<li>spdlog: \u4e00\u4e2a\u9ad8\u6027\u80fd\u3001\u529f\u80fd\u4e30\u5bcc\u7684 C&#043;&#043; \u65e5\u5fd7\u5e93\u3002<\/li>\n<p>\u6b65\u9aa4\u6307\u5357&#xff1a;<\/p>\n<p>1. \u5f15\u5165\u4f9d\u8d56<\/p>\n<p>\u786e\u4fdd\u4f60\u7684\u9879\u76ee\u5df2\u7ecf\u5305\u542b\u4e86 gflags \u548c spdlog \u5e93\u3002\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5668&#xff08;\u5982 vcpkg, conan&#xff09;\u6216\u76f4\u63a5\u4e0b\u8f7d\u6e90\u7801\u7f16\u8bd1\u96c6\u6210\u3002<\/p>\n<p>2. \u5b9a\u4e49\u547d\u4ee4\u884c\u53c2\u6570 (\u4f7f\u7528 gflags)<\/p>\n<p>\u5728\u4f60\u7684\u4e3b\u7a0b\u5e8f\u6587\u4ef6&#xff08;\u5982 main.cpp&#xff09;\u6216\u4e13\u95e8\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d&#xff0c;\u4f7f\u7528 DEFINE_xxx \u5b8f\u6765\u5b9a\u4e49\u4f60\u9700\u8981\u7684\u547d\u4ee4\u884c\u53c2\u6570\u3002\u5e38\u7528\u7c7b\u578b\u6709&#xff1a;<\/p>\n<p>#include &lt;gflags\/gflags.h&gt;<\/p>\n<p>\/\/ \u5b9a\u4e49\u5b57\u7b26\u4e32\u53c2\u6570&#xff0c;\u9ed8\u8ba4\u503c &#034;info&#034;&#xff0c; \u63cf\u8ff0 &#034;\u65e5\u5fd7\u7ea7\u522b&#034;<br \/>\nDEFINE_string(log_level, &#034;info&#034;, &#034;\u65e5\u5fd7\u7ea7\u522b (trace, debug, info, warn, error, critical, off)&#034;);<\/p>\n<p>\/\/ \u5b9a\u4e49\u6574\u6570\u53c2\u6570&#xff0c;\u9ed8\u8ba4\u503c 1048576&#xff0c; \u63cf\u8ff0 &#034;\u65e5\u5fd7\u961f\u5217\u5927\u5c0f&#034;<br \/>\nDEFINE_int32(log_queue_size, 1048576, &#034;\u5f02\u6b65\u65e5\u5fd7\u961f\u5217\u5927\u5c0f&#xff08;\u5b57\u8282&#xff09;&#034;);<\/p>\n<p>\/\/ \u5b9a\u4e49\u5e03\u5c14\u53c2\u6570&#xff0c;\u9ed8\u8ba4\u503c true&#xff0c; \u63cf\u8ff0 &#034;\u662f\u5426\u542f\u7528\u5f02\u6b65\u65e5\u5fd7&#034;<br \/>\nDEFINE_bool(log_async, true, &#034;\u542f\u7528\u5f02\u6b65\u65e5\u5fd7\u8bb0\u5f55&#034;);<\/p>\n<p>\/\/ \u5b9a\u4e49\u6587\u4ef6\u8def\u5f84\u53c2\u6570&#xff0c;\u9ed8\u8ba4\u503c\u7a7a&#xff0c; \u63cf\u8ff0 &#034;\u65e5\u5fd7\u6587\u4ef6\u8def\u5f84&#034;<br \/>\nDEFINE_string(log_file, &#034;&#034;, &#034;\u65e5\u5fd7\u6587\u4ef6\u8def\u5f84&#xff08;\u7a7a\u5219\u8f93\u51fa\u5230\u63a7\u5236\u53f0&#xff09;&#034;);<\/p>\n<p>\/\/ \u5176\u4ed6\u9700\u8981\u7684\u53c2\u6570&#8230;<\/p>\n<p>3. \u521d\u59cb\u5316 gflags \u548c \u89e3\u6790\u547d\u4ee4\u884c<\/p>\n<p>\u5728 main \u51fd\u6570\u5f00\u59cb\u5904&#xff0c;\u521d\u59cb\u5316 gflags \u5e76\u89e3\u6790\u547d\u4ee4\u884c\u53c2\u6570&#xff1a;<\/p>\n<p>int main(int argc, char** argv) {<br \/>\n    \/\/ \u521d\u59cb\u5316 gflags&#xff0c;\u89e3\u6790\u547d\u4ee4\u884c\u53c2\u6570<br \/>\n    gflags::ParseCommandLineFlags(&amp;argc, &amp;argv, true);<br \/>\n    \/\/ true \u8868\u793a\u79fb\u9664\u5df2\u89e3\u6790\u7684\u6807\u5fd7&#xff0c;argv \u53ea\u4fdd\u7559\u975e\u6807\u5fd7\u53c2\u6570<\/p>\n<p>    \/\/ &#8230; \u540e\u7eed\u7a0b\u5e8f\u903b\u8f91 &#8230;<br \/>\n}<\/p>\n<p>4. \u521d\u59cb\u5316 spdlog \u65e5\u5fd7\u7cfb\u7edf (\u57fa\u4e8e gflags \u53c2\u6570)<\/p>\n<p>\u4f7f\u7528 gflags \u5b9a\u4e49\u7684\u53c2\u6570\u503c\u6765\u914d\u7f6e spdlog \u65e5\u5fd7\u5668&#xff1a;<\/p>\n<p>#include &lt;spdlog\/spdlog.h&gt;<br \/>\n#include &lt;spdlog\/async.h&gt; \/\/ \u5f02\u6b65\u65e5\u5fd7\u9700\u8981<br \/>\n#include &lt;spdlog\/sinks\/basic_file_sink.h&gt;<br \/>\n#include &lt;spdlog\/sinks\/stdout_color_sinks.h&gt;<\/p>\n<p>    \/\/ \u6839\u636e log_level \u53c2\u6570\u8bbe\u7f6e\u5168\u5c40\u65e5\u5fd7\u7ea7\u522b<br \/>\n    std::string level_str &#061; FLAGS_log_level;<br \/>\n    spdlog::level::level_enum log_level &#061; spdlog::level::from_str(level_str); \/\/ \u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u65e5\u5fd7\u7ea7\u522b\u679a\u4e3e<\/p>\n<p>    \/\/ \u521b\u5efa sink&#xff08;\u8f93\u51fa\u76ee\u6807&#xff09;\u7684 vector<br \/>\n    std::vector&lt;spdlog::sink_ptr&gt; sinks;<\/p>\n<p>    \/\/ \u603b\u662f\u6dfb\u52a0\u63a7\u5236\u53f0 sink&#xff08;\u5e26\u989c\u8272&#xff09;<br \/>\n    sinks.push_back(std::make_shared&lt;spdlog::sinks::stdout_color_sink_mt&gt;());<\/p>\n<p>    \/\/ \u5982\u679c\u6307\u5b9a\u4e86\u65e5\u5fd7\u6587\u4ef6&#xff0c;\u6dfb\u52a0\u6587\u4ef6 sink<br \/>\n    if (!FLAGS_log_file.empty()) {<br \/>\n        try {<br \/>\n            auto file_sink &#061; std::make_shared&lt;spdlog::sinks::basic_file_sink_mt&gt;(FLAGS_log_file, true); \/\/ true \u8868\u793a\u622a\u65ad\u6587\u4ef6<br \/>\n            sinks.push_back(file_sink);<br \/>\n        } catch (const spdlog::spdlog_ex&amp; ex) {<br \/>\n            spdlog::error(&#034;\u521b\u5efa\u65e5\u5fd7\u6587\u4ef6\u5931\u8d25: {}&#034;, ex.what());<br \/>\n            \/\/ \u5904\u7406\u9519\u8bef&#xff0c;\u53ef\u80fd\u53ea\u4fdd\u7559\u63a7\u5236\u53f0\u65e5\u5fd7<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ \u521b\u5efa\u65e5\u5fd7\u5668<br \/>\n    std::shared_ptr&lt;spdlog::logger&gt; logger;<br \/>\n    if (FLAGS_log_async) {<br \/>\n        \/\/ \u521b\u5efa\u5f02\u6b65\u65e5\u5fd7\u5668 (\u9ad8\u6027\u80fd)<br \/>\n        spdlog::init_thread_pool(FLAGS_log_queue_size, 1); \/\/ \u961f\u5217\u5927\u5c0f\u6765\u81ea gflags \u53c2\u6570<br \/>\n        logger &#061; std::make_shared&lt;spdlog::async_logger&gt;(<br \/>\n            &#034;main_logger&#034;, sinks.begin(), sinks.end(), spdlog::thread_pool(),<br \/>\n            spdlog::async_overflow_policy::block \/\/ \u961f\u5217\u6ee1\u65f6\u963b\u585e<br \/>\n        );<br \/>\n    } else {<br \/>\n        \/\/ \u521b\u5efa\u540c\u6b65\u65e5\u5fd7\u5668<br \/>\n        logger &#061; std::make_shared&lt;spdlog::logger&gt;(&#034;main_logger&#034;, sinks.begin(), sinks.end());<br \/>\n    }<\/p>\n<p>    \/\/ \u8bbe\u7f6e\u65e5\u5fd7\u683c\u5f0f (\u53ef\u9009&#xff0c;\u6839\u636e\u9700\u8981\u81ea\u5b9a\u4e49)<br \/>\n    logger-&gt;set_pattern(&#034;[%Y-%m-%d %H:%M:%S.%e] [%^%l%$] [thread %t] %v&#034;);<\/p>\n<p>    \/\/ \u8bbe\u7f6e\u65e5\u5fd7\u7ea7\u522b (\u6765\u81ea gflags \u53c2\u6570)<br \/>\n    logger-&gt;set_level(log_level);<\/p>\n<p>    \/\/ \u6ce8\u518c\u4e3a\u5168\u5c40\u65e5\u5fd7\u5668 (\u53ef\u9009)<br \/>\n    spdlog::register_logger(logger);<br \/>\n    spdlog::set_default_logger(logger);<\/p>\n<p>    \/\/ &#8230; \u540e\u7eed\u7a0b\u5e8f\u903b\u8f91&#xff0c;\u5f00\u59cb\u4f7f\u7528 logger \u8bb0\u5f55\u65e5\u5fd7 &#8230;<\/p>\n<p>5. \u5728\u4ee3\u7801\u4e2d\u4f7f\u7528 spdlog \u8bb0\u5f55\u65e5\u5fd7<\/p>\n<p>\u5728\u7a0b\u5e8f\u7684\u4efb\u4f55\u5730\u65b9&#xff0c;\u90fd\u53ef\u4ee5\u4f7f\u7528 spdlog \u7684\u5b8f\u6216\u5168\u5c40 logger \u5bf9\u8c61\u8bb0\u5f55\u65e5\u5fd7&#xff1a;<\/p>\n<p>    \/\/ \u4f7f\u7528\u5168\u5c40\u9ed8\u8ba4\u65e5\u5fd7\u5668 (\u5982\u679c\u6ce8\u518c\u4e86)<br \/>\n    spdlog::info(&#034;\u7a0b\u5e8f\u542f\u52a8\u6210\u529f&#xff01;&#034;);<br \/>\n    spdlog::debug(&#034;\u8c03\u8bd5\u4fe1\u606f: \u53c2\u6570 log_level&#061;{}, log_async&#061;{}&#034;, FLAGS_log_level, FLAGS_log_async);<\/p>\n<p>    \/\/ \u6216\u8005\u4f7f\u7528\u547d\u540d\u7684\u65e5\u5fd7\u5668\u5bf9\u8c61 (\u63a8\u8350)<br \/>\n    logger-&gt;warn(&#034;\u8fd9\u662f\u4e00\u4e2a\u8b66\u544a\u4fe1\u606f&#xff01;&#034;);<br \/>\n    logger-&gt;error(&#034;\u53d1\u751f\u4e86\u4e00\u4e2a\u9519\u8bef&#xff01;\u9519\u8bef\u7801: {}&#034;, 404);<\/p>\n<p>    try {<br \/>\n        \/\/ &#8230; \u53ef\u80fd\u629b\u51fa\u5f02\u5e38\u7684\u4ee3\u7801 &#8230;<br \/>\n    } catch (const std::exception&amp; e) {<br \/>\n        logger-&gt;critical(&#034;\u53d1\u751f\u672a\u6355\u83b7\u7684\u5f02\u5e38: {}&#034;, e.what());<br \/>\n    }<\/p>\n<p>6. \u7a0b\u5e8f\u9000\u51fa\u524d\u6e05\u7406 (\u53ef\u9009)<\/p>\n<p>\u5728 main \u51fd\u6570\u8fd4\u56de\u524d&#xff0c;\u53ef\u4ee5\u663e\u5f0f\u5173\u95ed\u65e5\u5fd7\u7cfb\u7edf\u4ee5\u786e\u4fdd\u6240\u6709\u65e5\u5fd7\u6d88\u606f\u90fd\u88ab\u5237\u65b0&#xff1a;<\/p>\n<p>    \/\/ &#8230; \u7a0b\u5e8f\u7ed3\u675f\u524d\u7684\u4ee3\u7801 &#8230;<br \/>\n    spdlog::shutdown(); \/\/ \u5173\u95ed\u6240\u6709\u65e5\u5fd7\u5668\u5e76\u91ca\u653e\u8d44\u6e90<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\u7f16\u8bd1\u547d\u4ee4\u793a\u4f8b (Linux\/g&#043;&#043;)<\/p>\n<p>g&#043;&#043; -std&#061;c&#043;&#043;17 -O2 -o myapp main.cpp -lgflags -lspdlog -lpthread<\/p>\n<ul>\n<li>-std&#061;c&#043;&#043;17: \u6307\u5b9a C&#043;&#043; \u6807\u51c6\u7248\u672c&#xff08;spdlog \u5e38\u7528\u7279\u6027&#xff09;\u3002<\/li>\n<li>-O2: \u4f18\u5316\u7ea7\u522b\u3002<\/li>\n<li>-lgflags: \u94fe\u63a5 gflags \u5e93\u3002<\/li>\n<li>-lspdlog: \u94fe\u63a5 spdlog \u5e93\u3002<\/li>\n<li>-lpthread: \u94fe\u63a5 pthread \u5e93&#xff08;spdlog \u7684\u5f02\u6b65\u65e5\u5fd7\u9700\u8981&#xff09;\u3002<\/li>\n<\/ul>\n<p>\u4f7f\u7528\u793a\u4f8b<\/p>\n<p># \u9ed8\u8ba4\u53c2\u6570\u8fd0\u884c (\u65e5\u5fd7\u7ea7\u522binfo, \u5f02\u6b65, \u8f93\u51fa\u5230\u63a7\u5236\u53f0)<br \/>\n.\/myapp<\/p>\n<p># \u6307\u5b9a\u65e5\u5fd7\u7ea7\u522b\u4e3adebug&#xff0c;\u5173\u95ed\u5f02\u6b65&#xff0c;\u8f93\u51fa\u5230\u6587\u4ef6<br \/>\n.\/myapp &#8211;log_level&#061;debug &#8211;log_async&#061;false &#8211;log_file&#061;app.log<\/p>\n<p># \u67e5\u770b\u5e2e\u52a9 (gflags \u81ea\u52a8\u751f\u6210)<br \/>\n.\/myapp &#8211;help<\/p>\n<p>\u4f18\u52bf\u603b\u7ed3<\/p>\n<li>\u4fbf\u6377\u914d\u7f6e: gflags \u4f7f\u5f97\u547d\u4ee4\u884c\u53c2\u6570\u5b9a\u4e49\u3001\u89e3\u6790\u548c\u8bbf\u95ee\u53d8\u5f97\u6781\u5176\u7b80\u5355&#xff0c;\u7a0b\u5e8f\u884c\u4e3a\u9ad8\u5ea6\u53ef\u914d\u7f6e\u3002<\/li>\n<li>\u9ad8\u6027\u80fd\u65e5\u5fd7: spdlog \u7684\u5f02\u6b65\u65e5\u5fd7\u6a21\u5f0f\u80fd\u663e\u8457\u51cf\u5c11 I\/O \u963b\u585e&#xff0c;\u4fdd\u8bc1\u7a0b\u5e8f\u4e3b\u7ebf\u7a0b\u7684\u6027\u80fd&#xff0c;\u961f\u5217\u5927\u5c0f\u53ef\u8c03\u3002<\/li>\n<li>\u7075\u6d3b\u6027: \u65e5\u5fd7\u7ea7\u522b\u3001\u8f93\u51fa\u76ee\u6807&#xff08;\u63a7\u5236\u53f0\/\u6587\u4ef6&#xff09;\u3001\u683c\u5f0f\u5747\u53ef\u901a\u8fc7\u547d\u4ee4\u884c\u53c2\u6570\u6216\u4ee3\u7801\u52a8\u6001\u8c03\u6574\u3002<\/li>\n<li>\u6613\u7528\u6027: spdlog \u7684 API \u7b80\u6d01\u660e\u4e86&#xff0c;\u65e5\u5fd7\u8bb0\u5f55\u8bed\u53e5\u6e05\u6670\u6613\u8bfb\u3002<\/li>\n<li>\u7ebf\u7a0b\u5b89\u5168: \u4e24\u8005\u90fd\u652f\u6301\u591a\u7ebf\u7a0b\u73af\u5883\u3002<\/li>\n<p>\u901a\u8fc7\u9075\u5faa\u8fd9\u4e2a\u6307\u5357&#xff0c;\u4f60\u53ef\u4ee5\u8f7b\u677e\u5730\u5728\u4f60\u7684 C&#043;&#043; \u9879\u76ee\u4e2d\u5b9e\u73b0\u5f3a\u5927\u7684\u547d\u4ee4\u884c\u53c2\u6570\u5904\u7406\u548c\u9ad8\u6548\u3001\u7075\u6d3b\u7684\u65e5\u5fd7\u8bb0\u5f55\u529f\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u597d\u7684&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u5173\u4e8e\u5982\u4f55\u5728 C \u9879\u76ee\u4e2d\u7ed3\u5408\u4f7f\u7528 gflags \u8fdb\u884c\u547d\u4ee4\u884c\u53c2\u6570\u89e3\u6790\u548c spdlog \u5b9e\u73b0\u9ad8\u6027\u80fd\u65e5\u5fd7\u8bb0\u5f55\u7684\u5b9e\u6218\u6307\u5357\u3002<br \/>\n\u76ee\u6807&#xff1a; \u8ba9\u7a0b\u5e8f\u80fd\u591f\u65b9\u4fbf\u5730\u901a\u8fc7\u547d\u4ee4\u884c\u914d\u7f6e\u53c2\u6570&#xff0c;\u5e76\u5c06\u8fd0\u884c\u4fe1\u606f\u9ad8\u6548\u3001\u7075\u6d3b\u5730\u8bb0\u5f55\u5230\u65e5\u5fd7\u4e2d\u3002<br \/>\n\u6838\u5fc3\u7ec4\u4ef6&#xff1a;<br \/>\ngflags: Google \u7684\u547d\u4ee4\u884c\u6807\u5fd7\u5e93&#xff0c;\u7528\u4e8e\u89e3\u6790\u548c\u5b58\u50a8\u547d\u4ee4\u884c\u53c2\u6570\u3002spdlog: \u4e00\u4e2a\u9ad8\u6027\u80fd\u3001\u529f\u80fd\u4e30\u5bcc\u7684 C \u65e5\u5fd7\u5e93\u3002<br \/>\n\u6b65\u9aa4\u6307\u5357&#xff1a;<br \/>\n1. \u5f15\u5165\u4f9d\u8d56<br \/>\n\u786e\u4fdd\u4f60<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[87,43,44],"topic":[],"class_list":["post-67764","post","type-post","status-publish","format-standard","hentry","category-server","tag-87","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C++\u9ad8\u6548\u65e5\u5fd7\u4e0e\u547d\u4ee4\u884c\u89e3\u6790\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/67764.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C++\u9ad8\u6548\u65e5\u5fd7\u4e0e\u547d\u4ee4\u884c\u89e3\u6790\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u597d\u7684&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u5173\u4e8e\u5982\u4f55\u5728 C \u9879\u76ee\u4e2d\u7ed3\u5408\u4f7f\u7528 gflags \u8fdb\u884c\u547d\u4ee4\u884c\u53c2\u6570\u89e3\u6790\u548c spdlog \u5b9e\u73b0\u9ad8\u6027\u80fd\u65e5\u5fd7\u8bb0\u5f55\u7684\u5b9e\u6218\u6307\u5357\u3002 \u76ee\u6807&#xff1a; \u8ba9\u7a0b\u5e8f\u80fd\u591f\u65b9\u4fbf\u5730\u901a\u8fc7\u547d\u4ee4\u884c\u914d\u7f6e\u53c2\u6570&#xff0c;\u5e76\u5c06\u8fd0\u884c\u4fe1\u606f\u9ad8\u6548\u3001\u7075\u6d3b\u5730\u8bb0\u5f55\u5230\u65e5\u5fd7\u4e2d\u3002 \u6838\u5fc3\u7ec4\u4ef6&#xff1a; gflags: Google \u7684\u547d\u4ee4\u884c\u6807\u5fd7\u5e93&#xff0c;\u7528\u4e8e\u89e3\u6790\u548c\u5b58\u50a8\u547d\u4ee4\u884c\u53c2\u6570\u3002spdlog: \u4e00\u4e2a\u9ad8\u6027\u80fd\u3001\u529f\u80fd\u4e30\u5bcc\u7684 C \u65e5\u5fd7\u5e93\u3002 \u6b65\u9aa4\u6307\u5357&#xff1a; 1. \u5f15\u5165\u4f9d\u8d56 \u786e\u4fdd\u4f60\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/67764.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-28T22:17:09+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/67764.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/67764.html\",\"name\":\"C++\u9ad8\u6548\u65e5\u5fd7\u4e0e\u547d\u4ee4\u884c\u89e3\u6790\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-28T22:17:09+00:00\",\"dateModified\":\"2026-01-28T22:17:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/67764.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/67764.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/67764.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++\u9ad8\u6548\u65e5\u5fd7\u4e0e\u547d\u4ee4\u884c\u89e3\u6790\u5b9e\u6218\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C++\u9ad8\u6548\u65e5\u5fd7\u4e0e\u547d\u4ee4\u884c\u89e3\u6790\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/67764.html","og_locale":"zh_CN","og_type":"article","og_title":"C++\u9ad8\u6548\u65e5\u5fd7\u4e0e\u547d\u4ee4\u884c\u89e3\u6790\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u597d\u7684&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u5173\u4e8e\u5982\u4f55\u5728 C \u9879\u76ee\u4e2d\u7ed3\u5408\u4f7f\u7528 gflags \u8fdb\u884c\u547d\u4ee4\u884c\u53c2\u6570\u89e3\u6790\u548c spdlog \u5b9e\u73b0\u9ad8\u6027\u80fd\u65e5\u5fd7\u8bb0\u5f55\u7684\u5b9e\u6218\u6307\u5357\u3002 \u76ee\u6807&#xff1a; \u8ba9\u7a0b\u5e8f\u80fd\u591f\u65b9\u4fbf\u5730\u901a\u8fc7\u547d\u4ee4\u884c\u914d\u7f6e\u53c2\u6570&#xff0c;\u5e76\u5c06\u8fd0\u884c\u4fe1\u606f\u9ad8\u6548\u3001\u7075\u6d3b\u5730\u8bb0\u5f55\u5230\u65e5\u5fd7\u4e2d\u3002 \u6838\u5fc3\u7ec4\u4ef6&#xff1a; gflags: Google \u7684\u547d\u4ee4\u884c\u6807\u5fd7\u5e93&#xff0c;\u7528\u4e8e\u89e3\u6790\u548c\u5b58\u50a8\u547d\u4ee4\u884c\u53c2\u6570\u3002spdlog: \u4e00\u4e2a\u9ad8\u6027\u80fd\u3001\u529f\u80fd\u4e30\u5bcc\u7684 C \u65e5\u5fd7\u5e93\u3002 \u6b65\u9aa4\u6307\u5357&#xff1a; 1. \u5f15\u5165\u4f9d\u8d56 \u786e\u4fdd\u4f60","og_url":"https:\/\/www.wsisp.com\/helps\/67764.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-28T22:17:09+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/67764.html","url":"https:\/\/www.wsisp.com\/helps\/67764.html","name":"C++\u9ad8\u6548\u65e5\u5fd7\u4e0e\u547d\u4ee4\u884c\u89e3\u6790\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-28T22:17:09+00:00","dateModified":"2026-01-28T22:17:09+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/67764.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/67764.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/67764.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C++\u9ad8\u6548\u65e5\u5fd7\u4e0e\u547d\u4ee4\u884c\u89e3\u6790\u5b9e\u6218"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/67764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=67764"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/67764\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=67764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=67764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=67764"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=67764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}