mcpp index

compat.argparse

#include

argparse — header-only argument parser for modern C++

#include <argparse/argparse.hpp>
mcpp add compat.argparse@3.2

用法

來自本倉庫自己的測試專案 —— CI 真的編譯並執行過,不是為了網站寫的。

// Behavioral test — compat.argparse parses a command line, it does not merely
// include.
//
// argv is written by hand rather than taken from the runner, so the assertions
// are about argparse's behaviour and not about how `mcpp test` invokes a
// binary. No `import std;`: argparse.hpp is a textual header over the standard
// library.
#include <argparse/argparse.hpp>

#include <iostream>
#include <string>
#include <vector>

int main() {
    argparse::ArgumentParser program("renderer", "0.1.0");
    program.add_argument("model").help("path to the glTF model");
    program.add_argument("--width").default_value(1280).scan<'i', int>();
    program.add_argument("--validate").default_value(false).implicit_value(true);

    const std::vector<std::string> argv{"renderer", "scene.gltf", "--width", "1920", "--validate"};
    try {
        program.parse_args(argv);
// …

tests/examples/argparse/tests/parse.cpp · 專案 tests/examples/argparse

openkal

目標結果環境測試專案首條診斷
x86_64-linux-gnurunsposixargparse
x86_64-windows-muslrunsposixargparse

測量方式

2026-09-23 由 tests/openkal/compat.py 測得,使用 openkal-llvm-runtime 0.15.1、llvm@22.1.8、mcpp 2026.9.21.3。測試專案沒有自行選擇平台相依。 上方徽章是所有已測目標裡最嚴格那個的結果 —— 上表列出每個目標各自的環境。

建置

targets
argparse (lib)
language
c++23
C standard
c11
import std
no
include dirs
*/include

原始檔 (1)

  • mcpp_generated/argparse_anchor.c

產生的檔案

  • mcpp_generated/argparse_anchor.c

版本

版本平台 鏡像sha256
3.2 最新 LinuxWindowsmacOS CN GLOBAL 9dcb3d8ce0a4…