Basically, std :: vector does NOT match (in memory layout or something) as a char * array. To resolve this, you need to make the compiler recognize the new main declaration and add a wrapper to the record that created the row vector.
Given that you were doing this, you could also throw argc as well as declare the main
int main(std::vector<std::string> argv)
But it works for the compiler. You would need to get a lot of people who thought it was worth it.
Otherwise, you can just do it yourself
int main(int argc, char **argv) { std::vector<std::string> args; args.reserve(argc); for (std::size_t arg = 0; arg < argc; ++arg) { args.push_back(argv[i]); } return mymain(args); }
The code is not guaranteed to compile or work because I just wrote it from my head.
or (better, thanks to AProgrammer)
int main(int argc, char **argv) { return mymain(std::vector<std::string>(argv, argv + argc)); }
Tom Tanner Aug 22 '12 at 12:11 2012-08-22 12:11
source share