Help with getopts_long()

I'm trying to use getopts_long to process command line arguments. I need to setup an option array to pass to getopts_long. But when I compile I get the error.


wbadinitl: String literal converted to char* in initialization


1
2
3
4
5
6
7
8
9
10
    static struct option long_options[] =
        {
            {"first-page", required_argument, 0, 'f'},
            {"add",     no_argument,       0, 'a'},
            {"append",  no_argument,       0, 'b'},
            {"delete",  required_argument, 0, 'd'},
            {"create",  required_argument, 0, 'c'},
            {"file",    required_argument, 0, 'f'},
            {0, 0, 0, 0}
        };


The only way I can get around with is by doing

1
2
string VersbosityString = "verbosity";
char *verbosityCharPointer = (char*) stringVersbosity.c_str();


But this is making my code very verbose. Is their another way around this.
The type of a string literal is const char* so if you change it to that in your struct, it should be fine. Oddly, compilers don't usually complain about this problem..
Topic archived. No new replies allowed.