• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: main() vs getopt() signature mismatch
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: main() vs getopt() signature mismatch


  • Subject: Re: main() vs getopt() signature mismatch
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Fri, 25 Oct 2013 08:51:10 +0200

Le 25 oct. 2013 à 02:02, Todd Heberlein <email@hidden> a écrit :

> I’ve noticed the argv variable in main() and getopt() are declared differently (the “const” is in a different place):
>
> 	const char * argv[]
> 	char * const argv[]
>
> int main(int argc, const char * argv[])
> int getopt(int argc, char * const argv[], const char *optstring)
>
> My work arounds are either to
>
> (1) cast argv in the get opt() call:
>
> while ((c = getopt(argc, (char * const *)argv, "smx")) != -1) {
> }
>
> (2) or redefine main()
>
> int main(int argc, char * const argv[])
>
>
> Any idea of the right way to deal with the argv difference in main() and getopt()?
>
> Todd

What about changing main to "int main(int argc, char *argv[])" as defined in the C standard (section 5.1.2.2.1) ?

-- Jean-Daniel





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: main() vs getopt() signature mismatch
      • From: Todd Heberlein <email@hidden>
References: 
 >main() vs getopt() signature mismatch (From: Todd Heberlein <email@hidden>)

  • Prev by Date: Re: Where are my man pages?
  • Next by Date: Re: Where are my man pages?
  • Previous by thread: main() vs getopt() signature mismatch
  • Next by thread: Re: main() vs getopt() signature mismatch
  • Index(es):
    • Date
    • Thread