I am using program_options on an app that I am compiling for linux and
windows (vs2005). I have found that long option descriptions cause a
fatal error on windows when they are long enough that they need to wrap
to the next line. (I'm having no problem in linux). If I run the debug
version I get an assertion failed in xstring. Release just gives a fatal
error.
The following code causes the problem:
#include <iostream>
#include
using namespace std;
namespace po = boost::program_options;
using namespace boost;
int main( int argc, char *argv[] )
{
string tmp;
// Declare a group of options that will be
// allowed only on command line
po::options_description cmdline_options("Usage: programOptionsTest
[options] - Allowed Options blah blah blah blah blah blah blah blah");
cmdline_options.add_options()
("help,h", "produce this help message a b c d e f g h i j k l m
n o p");
cout << cmdline_options << endl;
cin >> tmp;
return 0;
}
Note that the "blah blah blah..." part is wrapped ok, but the "help"
line need to wrap after the "o" and crashes. If I remove the "p" from
the string then it doesn't need to wrap and everything is ok. (You might
need to adjust the string to cause wrapping if you console width is
different then mine.)
/**************************************
* Scott Finley
* Research Software Engineer
* TomoTherapy Inc.
* Email: sfinley@tomotherapy.com
* Phone: 608.824.3381
***/