• 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
main() vs getopt() signature mismatch
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

main() vs getopt() signature mismatch


  • Subject: main() vs getopt() signature mismatch
  • From: Todd Heberlein <email@hidden>
  • Date: Thu, 24 Oct 2013 17:02:16 -0700

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


 _______________________________________________
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: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Re: Updating build number for built product only
  • Next by Date: Re: Updating build number for built product only
  • Previous by thread: Re: Updating build number for built product only
  • Next by thread: Re: main() vs getopt() signature mismatch
  • Index(es):
    • Date
    • Thread