[Vala] Need Help with GLib.OptionEntry



Hi,

I write a program which need command line arguments. I want to
implement this feature with the command line parser of the GLib. I read
the C and the Vala reference of the related topics but get an error
with the C compiler. Maybe knows somebody what goes wrong.


Error messages:

error: incompatible types when initializing type ‘enum <anonymous>’
using type ‘char **’
error: incompatible types when initializing type ‘enum <anonymous>’
using type ‘gboolean *’
error: incompatible types when initializing type ‘enum <anonymous>’
using type ‘gboolean *’
error: incompatible types when initializing type ‘enum <anonymous>’
using type ‘gint *’


An here is the related code:

string pre;
string post;
string filename;
bool interactive;
bool conserve;
int start;

const OptionEntry[] entries = {
    { "pre", 0, 1, OptionArg.STRING, ref pre, "set prefix that will be
placed to the left of the number", "PREFIX" }, { "post", 0, 1,
OptionArg.STRING, ref post, "set postfix that will be placed to the
left of the number", "POSTFIX" }, { "list", 'l', OptionArg.FILENAME,
ref filename, "use a list of files instead of all files in the
directory", "LIST" }, { "interactive", 'i', OptionArg.NONE, ref
interactive, "choose which files should be renamed interactive",
null }, { "conserve", 'c', OptionArg.NONE, ref conserve, "conserve file
extension", null }, { "start", 's', OptionArg.INT, ref start, "set
startnumber", "START" } };

static int main(string[] args) {
    var opt_context = new OptionContext("- Options for simpleRenamer");

    opt_context.set_help_enabled(true);
    opt_context.add_main_entries(entries, null);

    try {
        opt_context.parse(ref args);
    }
    catch(OptionError error) {
        stdout.printf("%s", error.message);
    }

    return 0;
}


Regards,

Karsten



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]