mcpp index

compat.argparse

#include

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

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

Usage

From this repository's own test project — built and run by CI, not written for the website.

// 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 · project tests/examples/argparse

openkal

targetresultenvironmenttest projectfirst diagnostic
x86_64-linux-gnurunsposixargparse
x86_64-windows-muslrunsposixargparse

How this was measured

Measured 2026-09-23 by tests/openkal/compat.py with openkal-llvm-runtime 0.15.1, llvm@22.1.8, mcpp 2026.9.21.3. The test project selects no platform dependency of its own. The badge above is a summary of the strictest measured target -- the table above states each target's own environment.

Build

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

Sources (1)

  • mcpp_generated/argparse_anchor.c

Generated files

  • mcpp_generated/argparse_anchor.c

Versions

VersionPlatforms Mirrorssha256
3.2 latest LinuxWindowsmacOS CN GLOBAL 9dcb3d8ce0a4…