• # argc, argv

    Posté par . En réponse au message Rendre un parametre de programme obligatoire. Évalué à 1.

    teste la valeur argc. Si elle et égale à 1, alors il n'ya aucun argument passé. Si argc est supérieur à 1, il te suffit de tester l'argument que tu désires obligatoire voir s'il est saisi.

    Il te faut utiliser aussi la fonction suivante :
    gboolean g_option_context_parse (GOptionContext *context,
    gint *argc,
    gchar ***argv,
    GError **error);

    Parses the command line arguments, recognizing options which have been added to context. A side-effect of calling this function is that g_set_prgname() will be called.

    If the parsing is successful, any parsed arguments are removed from the array and argc and argv are updated accordingly. A '--' option is stripped from argv unless there are unparsed options before and after it, or some of the options after it start with '-'. In case of an error, argc and argv are left unmodified.

    If automatic --help support is enabled (see g_option_context_set_help_enabled()), and the argv array contains one of the recognized help options, this function will produce help output to stdout and call exit (0).

    context : a GOptionContext
    argc : a pointer to the number of command line arguments.
    argv : a pointer to the array of command line arguments.
    error : a return location for errors
    Returns : TRUE if the parsing was successful, FALSE if an error occurred

    Since 2.6


    Elle intègre toutes les options passées en ligne de commande dans le GOptionContext *context