You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have a hpx_main function giving you access to the hpx variables through the variables_map and as well to the argv and argc containing the left over command line options.
This would help a lot to port existing codes using argc and argv to hpx.
The text was updated successfully, but these errors were encountered:
this is already possible: IIUC, you would like to not only keep the command line option handling of an existing application in place but you would like to be able to additionally define your own options.
using boost::program_options;
int hpx_main(variable_map& vm)
{
// vm will hold the information about all command line options described
// by the options_description below
// you can access the unknown command line here:
std::string unknown_command_line =
hpx::get_config_entry("hpx.unknown_cmd_line", "");
#if defined(BOOST_WINDOWS)
std::vector<std::string> args = split_winmain(unknown_command_line);
#else
std::vector<std::string> args = split_unix(unknown_command_line);
#endif
// handle the 'old' options...
}
int main(int argc, char* argv[])
{
// Configure application-specific options
options_description desc_commandline(
"Usage: " HPX_APPLICATION_STRING " [options]");
desc_commandline.add_options()
( "foo", "some value")
;
// allow for unknown options
std::vector<std::string> cfg;
cfg.push_back("hpx.commandline.allow_unknown=1");
return hpx::init(desc_commandline, argc, argv, cfg);
}
Let me know if that's not what you need, there are many more options for handling command line arguments in HPX.
That looks interesting. i did't know that hpx::get_config_entry("hpx.unknown_cmd_line", "") exist.
From the args:std::vector<std::string> it should be no problem to generate argc:int and argv:char** data structures used by the original program.
I think this solves my problems. Thanks
It would be nice to have a hpx_main function giving you access to the hpx variables through the variables_map and as well to the argv and argc containing the left over command line options.
This would help a lot to port existing codes using argc and argv to hpx.
The text was updated successfully, but these errors were encountered: