Skip to content

ArgKind

Description

Type tag for a target variable, computed at compile time via _Generic. Drives both value-string parsing and the metavar / error-message wording.

Usage example (Cross-references)

Usage examples (Cross-references)
    // Human-readable type name used in invalid-value error messages. Lines
    // up 1:1 with the ArgKind enum; new entries get a label here.
    static const char *arg_kind_label(ArgKind k) {
        switch (k) {
            case ARG_KIND_ZSTR :
    // false on type-mismatch / out-of-range so the caller can emit a
    // "invalid value 'X' for --flag: expected <type>" message.
    static bool store_value(ArgKind kind, void *target, const char *value) {
        switch (kind) {
            case ARG_KIND_ZSTR : {
    // to unsigned-int kinds at registration time; signed counters would
    // give surprising wrap-around semantics for repeated flags.
    static bool count_bump(ArgKind kind, void *target) {
        switch (kind) {
            case ARG_KIND_U8 :
            ARG_KIND_F32,
            ARG_KIND_F64,
        } ArgKind;
    
        ///
        ///
        typedef struct ArgTarget {
            ArgKind kind;
            void   *target;
        } ArgTarget;
            const char *help;       // one-line description for `--help`
            ArgRole     role;
            ArgKind     kind;
            void       *target;
            bool        seen; // set during parse so missing-required can be checked
Last updated on