My code was running like a charm until a few minutes ago. I Have already tried to restart XCode, my computer and nothing happens. This is the snippet that matters:
int main(int argc, const char * argv[]) {
string input_collection_index;
string input_directory;
bool is_retrieval=false;
bool is_merge = false;
//Arguments parsing
for(unsigned i = 1; i < argc; ++i) {
string param = argv[i];
//index file name
if(param == "--index" || param == "-i") {
i++;
input_collection_index = argv[i];
}
//index file path
else if (param == "--directory" || param == "-d") {
i++;
input_directory = argv[i];
}
else if (param == "--retrieval" || param == "-r") {
is_retrieval = true;
}
else if (param == "--merge" || param == "-m"){
is_merge = true;
}
}
}
Here is my scheme:
I keep receiving the following error:
Note that the address of the bad access is not 0x00, so, it's not null. The XCode debugger shows me that argc has the right length, and that argv (at least argv[0]) is the right string (file path). Any ideas?
So, the problem is deeper and related do C++, not XCode itself, I think. After the snippet above, I was creating a class that had this member:
unsigned output_buffer_[9999999];
changing it to
unsigned *output_buffer_;
and then allocating it latter in my code with:
output_buffer_ = (unsigned*) malloc(9999999*sizeof(unsigned))
made it work. Maybe something related to how the compiler deals with statically allocated arrays.