GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Oct 24, 2014 8:33 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: system command
PostPosted: Fri Oct 05, 2012 5:58 pm 
Offline
Familiar Face

Joined: Sat Mar 03, 2012 2:45 am
Posts: 18
Hello on my call back i am trying to open up a terminal and calling a script with a variable. I can't get it to comple. I get error "/home/myusername/myproject/src/main.c:58:80: error: conflicting types for ‘filename’" - Both are gchars. it might be in the gchar *setup line. It sounds like to me it's not combining the gchars. The script works if i manually enter it into gnome-terminal. Any Help?

I am using GTK3, Ubuntu 12.04

Code:
void btn_choose_iso_file_set_cb (GtkWidget *btn_choose_iso, gpointer data)
{
   gchar *filename = gtk_file_chooser_get_filename (GTK_WIDGET(btn_choose_iso));

   gchar *setup = "gnome-terminal -e /home/myusername/myproject/scripts/setupfs %s", filename;

   system(setup);
}


Thank You


Top
 Profile  
 
 Post subject: Re: system command
PostPosted: Fri Oct 05, 2012 7:39 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hi.

What exactly should this line of code do:
Code:
gchar *setup = "gnome-terminal -e /home/myusername/myproject/scripts/setupfs %s", filename;


You'll probably want to call some function to do the string processing (something like snprintf() from libc or g_strdup_printf() from glib).

Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: system command
PostPosted: Fri Oct 05, 2012 10:29 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
I can see why you're getting the conflict error though. Both aren't gchars. You have two lines of declarations. The first declares filename as gchar* and the second as gchar (the comma in your second one is used for delimiting a list of variables to be declared). In order to avoid this confusion it may help to separate your declarations/initialisations from your main code. Of course as Tadej has pointed out your second line should be expressed differently regardless; my vote would be g_strdup_printf. With a function call bracketing both the "gnome-terminal...%s" string and the filename variable, the compiler will no longer see it as a delimited list of items being declared.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group