title: C Warning passing argument 2 of ‘getopt’ from incompatible pointer type
body: <p>I write a function with <code>getopt()</code> to get options from the command line. When I compile it, I get this Warning:</p>
  
  <pre><code>cc1: warnings being treated as errors
  csim.c: In function ‘getArg’:
  csim.c:157: error: passing argument 2 of ‘getopt’ from incompatible 
  pointer type /usr/include/getopt.h:152: note: expected ‘char * const*’ 
  but argument is of type ‘const char **’
  </code></pre>
  
  <p>Here is the C code:</p>
  
  <pre><code>#include &lt;ctype.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  int main(){
  }
  
  int getArg(int argc, char const *argv[], int *verbose, int *ps, 
      int *pE, int *pb, char *traceFileName){
      int arg;
      int argCount;
      while ((arg = getopt(argc, argv, "vs:E:b:t:")) != -1){
          switch (arg){
              case 'v':
              *verbose = 1;
              break;
  
              default:
              printf("%s\n", "Illegal command arguments, please input again");
              exit(-1);
              break;
          }
      }
  
      if(argCount &lt; 4){
          printf("%s\n", "Illegal command arguments, please input again");
              exit(-1);
      }
      return 0;
  }
  </code></pre>