Below is a small program that demonstrates some of the problems I've
been having. It takes one positional parameter, "limit" which is of type
size_t. I'm linking statically with debug symbols.
With the "try" in the position shown, after the declaration of vm, this is
what happens to me for different command line arguments:
* --limit=4 => works and prints limit=4
* --limt=4 => [notice misspelling] throws "unknown option limt" exception;
but also triggers Dr. Watson: Application Error - The instruction at
"0x0042eb49" referenced memory at "0x010900fb". The memory
could not be "written".
* --limit=-4 => [note negative value] never exits store(). Gets Dr.
Watson "The instruction at "0x0049c090" referenced memory at
"0x00eab651". The memory could not be "written.
* --limit=xxx => [note string value] never exits store(). Get Dr. Watson
with same message as above.
Now, move the "try" to immediately after main() so all of the program
options code is included in the try block.
* --limit=4 => works as before
* --limt=4 => [notice misspelling] Does NOT throw expected "unknown
option" exception, never exits store(), but does trigger Dr. Watson, this
time trying to read location 0xd.
* --limit=-4 => similar error to above, with slightly different addresses.
* --limt=xxx => similar error to above with slightly different addresses.
Enjoy,
Merrill
//==========================================
#include <iostream>
#include "boost/program_options.hpp"
using namespace std;
namespace po = boost::program_options;
int main(int argc, char* argv[]) {
// try {
po::options_description general("Option");
general.add_options()
("limit",
po::value