1

during compiling older C++ code on Ubuntu 11.10 with mpic++ (Open MPI C++ wrapper compiler) I got this warning connected with int main(int argc, char **argv){...}:

main(int, char**) : warning: deprecated conversion from string constant to ‘char*’

I tried to edit the code to int main(int argc, const char *argv[]){...} but it did not help (contrary to e.g. this issue).

What did I wrong? How can I fix it?

Community
  • 1
  • 1
user1013619
  • 149
  • 1
  • 1
  • 3
  • It was probably in some code that you haven't shown us. In C++, the `int` is required, so you should have `int main(int argc, char **argv)`. What happens when you just have an empty program: `int main(int argc, char **arg) { }`? – Keith Thompson Oct 29 '11 at 01:26
  • If I have an empty program `int main(int argc, char **argv) { }` there is no warning message. In the program (between `{ }` ) I use `argv` on two lines: `#ifdef PARALLEL MPI_err = MPI_Init(&argc, &argv); #endif parameter p(argc, argv); ` In `parameter::parameter(int argc, char **argv)` (where commandline parameters are checked) it is used on these lines `strcpy(my_name,argv[0]); strcpy( input_file_name, argv[1] );`. – user1013619 Oct 29 '11 at 09:16
  • 2
    As I suspected, the error was in the code that you replaced with `...`. Narrow your program down to the minimal *complete* program that reproduces the problem; post that program and the exact error m message you get, clearly indicating the line that the error message refers to. Do this by editing your question, not in a comment (you can't do proper formatting in comments). – Keith Thompson Oct 29 '11 at 20:30

0 Answers0