Created
August 3, 2012 14:43
-
-
Save pesterie/3248248 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In a header file | |
#include <user_main_fwd.hpp> | |
#define main nt2::user_main | |
//In a library | |
#include <...> | |
int hpx_main(boost::program_options::variables_map& vm) | |
{ | |
std::vector<std::string> args; | |
bool condition = nt2::details::get_args(args); | |
BOOST_ASSERT_MSG( condition == true | |
, "Enable to parse command line arguments on this system." | |
); | |
int argc = args.size(); | |
char **argv= (char**)malloc(argc*sizeof(char*)); | |
std::vector<std::string>::iterator it = args.begin(); | |
for(std::size_t i=0; i < args.size(); i++) | |
{ | |
std::string tmp = *it++; | |
tmp+='\0'; | |
argv[i] = (char*)malloc((tmp.size())*sizeof(char)); | |
tmp.copy(argv[i], tmp.size(), 0); | |
} | |
{ | |
// Just need a forward declaration | |
nt2::user_main(argc,argv); | |
} | |
return hpx::finalize(); | |
} | |
int main(int argc, char *argv[]) | |
{ | |
boost::program_options::options_description cmdline("Usage: " HPX_APPLICATION_STRING " [options]"); | |
return hpx::init(cmdline, argc, argv); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment