I am looking for a C or C++ open-source library for exposing configuration-related variable via an API and a web UI. The requirements are:

R1. It should be non-intrusive for the programmer. Assume an existing code has a global variable const bool show_fps = false (i.e., a debugging relic), a programmer should be able to write something like:

bool show_fps = true;  // only "const" is removed
CONFIG(&show_fps,  // variable
    "debug.show_fps",  // API identifier
    "Show FPS",  // short user-friendly title
    "Enable/disable displaying the number of frames per second of the video pipeline",  // long user-friendly description

R2. It should expose an API (e.g., REST, line-oriented) which allows:

  • to list configuration variables, their user-friendly title and their description;
  • to determine their current value;
  • to set the value of a variable.

R3. It should expose a single-page web UI which present the above API in a user-friendly manner.

Since, I got the question previously: I know that C and C++ are not the same thing, however, I believe that writing an adapter from one language to another implies a lot less effort that writing a library fulfilling the above requirements from scratch. Hence, I am open to both C and C++ libraries.

Below are some examples of libraries and frameworks I came across during my research and why they fall short:

  • Boost program_options fits R1 quite nicely:

    int opt;
    po::options_description desc("Allowed options");
        ("optimization", po::value<int>(&opt)->default_value(10), "optimization level")

    However, it seems to be geared towards the command-line, environment variables and configuration files, hence not fulfilling R2 and R3.

  • I drew a lot of inspiration from the Linux kernel's moduleparam.h header:

    static int max_loop;
    module_param(max_loop, int, 0444);
    MODULE_PARM_DESC(max_loop, "Maximum number of loop devices");

    It fits requirement R1 quite well. R2 is almost fulfilled, i.e., said configuration can be manipulated via sysfs, however, an API that is not kernel-specific is required. R3 is not fulfilled.

  • etcd is an excellent server-software for storing key-value configuration variables organized as a tree, partially fulfilling R2 and R3. However, it does not have a notion of user-friendly title and description for each variable. Furthermore, I found no library to integrate with it non-intrusively (R1).

  • 1
    Welcome aboard. This is a great question (+1). Unfortunately, I don't know the answer, but I do hope that someone else does, as this could be very useful
    – Mawg
    Jan 7, 2019 at 11:41

1 Answer 1


I ended up writing my own library under a MIT license. If anybody ever has the same problem feel free to use it: https://github.com/cristiklein/cpprestconfig

Contributions welcome!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.