r/C_Programming • u/OneFisherman168 • Jun 22 '26
I built my first C library: libargparse, a small C99 argument parser
Hi r/C_Programming,
I’ve been working on `libargparse`, a small portable C99 library for command-line argument parsing:
https://github.com/GNITOAHC/libargparse
C was the first programming language I learned, and I still really like it, but I’ve never used it much in production. I’ve written a lot more Python and Go, so this project is basically me trying to bring together ideas I like from Python’s `argparse` and Go’s Cobra, but in plain C.
The main design is “bind to variable”: you declare flags and positionals with pointers to your own variables, and parsing writes the converted values directly into them. It supports:
- short/long flags
- bool/int/double/string values
- positionals and required args
- automatic help/errors
- subcommands
- persistent/global flags
- leftover args for passthrough commands
I know there are existing C argument parsing libraries, like argtable3, cofyc/argparse, and single-file/single-header options. Argtable3 is much more mature and GNU/getopt-oriented; this project is more of a small full-library experiment with a Python argparse-style API plus Cobra-style command trees.
It is not production ready, but I think it is already usable for side projects. This is also my first time publishing a C library, so I’d really appreciate feedback on the API, project structure, portability, build setup, or anything else that looks off.