我正在尝试制作一个副本,char *argv[]
以便我可以将它们传递给一个需要char**
. 首先,我必须从原始文件中删除一些标志argv
:
int main(int argc, char* argv[]) {
::MessageBox(0,"Stopped at the entry point",0,0);
std::string inChannelParam = "--ipc-in-channel";
std::string outChannelParam = "--ipc-out-channel";
std::string inChannelName;
std::string outChannelName;
std::vector<std::string> argv_copy;
for(int i=0; i<argc; ++i) {
if(inChannelParam == argv[i]) {
if(++i < argc) {
inChannelName = argv[i];
continue;
}
} else if(outChannelParam == argv[i]) {
if(++i < argc) {
outChannelName = argv[i];
continue;
}
}
argv_copy.push_back(argv[i]);
}
std::vector<std::unique_ptr<char[]> > argv_copy_char;
for(int i=0;i<argv_copy.size();++i) {
argv_copy_char.push_back(std::unique_ptr<char[]>(new char[argv_copy[i].size()+1]));
memcpy(argv_copy_char[i].get(), &argv_copy[i][0], argv_copy[i].size());
argv_copy_char[i][argv_copy[i].size()] = '\0';
}
// what should i put here ?? --------------------vvv
v8::V8::SetFlagsFromCommandLine(&argc, &(argv_copy_char[0].get()), true);
我尝试了基于字符串和 char [] 的方法。它给出了编译器错误:
error C2102: '&' requires l-value
使用&(argv_copy_char[0]._Myptr)
给我运行时错误
if (arg != NULL && *arg == '-') {
在flags.cc
.
函数 SetFlagsFromCommandLine 的签名是
SetFlagsFromCommandLine (int *argc, char **argv, bool remove_flags)
.
我应该怎么办 ?