xcode C++ - getopt_long

Discussion in 'Mac Programming' started by alexWoz, Sep 12, 2009.

  1. alexWoz macrumors newbie

    Joined:
    Sep 12, 2009
    #1
    For a C++ project in class I am required to parse command line options with two dashes in front of them (i.e. "--Stack" "--Time" etc). It was recommended we use getopt_long to help parse these options. However, while I know how to give my program arguments with a single dash, I cannot figure out how to do "long options" with the double dash. Does xcode support these types of arguments? Any help would be appreciated.
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Read The Fine Man Page.

    In Xcode, under the Help Menu, there is an item to read a man page. Choose that, then enter getopt_long. The man page for the function should appear.

    By the way, it's not Xcode that supports these types of arguments, it's the getopt_long() function in the standard C library. You can use this function even if you're not using Xcode, e.g. if you were using gcc at the command-line, or a makefile.
     
  3. alexWoz thread starter macrumors newbie

    Joined:
    Sep 12, 2009
    #3
    Thanks for your reponse! I had no idea those man pages existed--definitely helpful. However, I'm still kind of confused... if I'm compiling my app within xcode, how can I pass those types of arguments? It works fine on a linux command line through university computers, but I would like to know how to do it within the xcode environment.

    ** EDIT **

    Figured it out... just needed to put two dashes before the argument! Thanks again for your help.
     

Share This Page