LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-03-2003, 04:59 PM   #1
JStew
Member
 
Registered: Oct 2002
Location: North Atlanta
Distribution: LFS
Posts: 229

Rep: Reputation: 30
Getting an incompatible pointer type error...


Here is my compile error:
[philip@mandrake Chapter3]$ gcc first.c -o first `gtk-config --cflags` `gtk-config --libs`
first.c: In function `main':
first.c:46: warning: passing arg 4 of `gtk_signal_connect_object' from incompatible pointer type
first.c:51: warning: passing arg 4 of `gtk_signal_connect_object' from incompatible pointer type
first.c:57: warning: passing arg 4 of `gtk_signal_connect_object' from incompatible pointer type
first.c:62: warning: passing arg 4 of `gtk_signal_connect_object' from incompatible pointer type
first.c:80:1: warning: no newline at end of file
/tmp/ccLnVwxD.o: In function `Update':
/tmp/ccLnVwxD.o(.text+0x2d): undefined reference to `strcopy'
collect2: ld returned 1 exit status

here is the code:
---------------------------------------------------------------------------------
#include<stdio.h>
#include<time.h>
#include<gtk/gtk.h>


void Update (GtkWidget *widget, char *timestr)
{
time_t timeval;

timeval = time( NULL );
strcopy (timestr, ctime( &timeval));
}


void PrintAndExit(GtkWidget *widget, char timestr[][26])
{
int i;

for (i = 0; i < 4; i++)
printf("timestr[%d] is %s", i, timestr[i]);
gtk_main_quit();
}


int main(int argc, char *argv[])
{
GtkWidget *window, *box, *button;

static char times[4][26] = {"Unset\n", "Unset\n", "Unset\n", "Unset\n"};

gtk_set_locale();
gtk_init (&argc, &argv);

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

gtk_signal_connect (GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(PrintAndExit), times);

gtk_window_set_title (GTK_WINDOW (window), "Signals 1");
gtk_container_border_width (GTK_CONTAINER (window), 0);

box = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), box);

button = gtk_button_new_with_label ("Update 0");
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (Update), &times[0]);
gtk_box_pack_start (GTK_BOX (box), button, TRUE, TRUE, 0);

button = gtk_button_new_with_label ("Update 1");
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (Update), &times[1]);
gtk_box_pack_start (GTK_BOX (box), button, TRUE, TRUE, 0);


button = gtk_button_new_with_label ("Update 2");
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (Update), &times[2]);
gtk_box_pack_start (GTK_BOX (box), button, TRUE, TRUE, 0);

button = gtk_button_new_with_label ("Update 3");
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (Update), &times[3]);
gtk_box_pack_start (GTK_BOX (box), button, TRUE, TRUE, 0);

gtk_widget_show_all(window);

gtk_main();

return (0);
}
------end of code--------------------------------------------
I thought maybe that I wasnt declaring times as a pointer but that had nothing to do with the error... Anyone know why I might be getting this error?
 
Old 03-03-2003, 05:01 PM   #2
JStew
Member
 
Registered: Oct 2002
Location: North Atlanta
Distribution: LFS
Posts: 229

Original Poster
Rep: Reputation: 30
A thing of note:
you see the x[array_index_num} ?
in my code in the file that should say "&times"
something funny i guess this board does with leading ampersands
 
Old 03-03-2003, 05:02 PM   #3
JStew
Member
 
Registered: Oct 2002
Location: North Atlanta
Distribution: LFS
Posts: 229

Original Poster
Rep: Reputation: 30
man.. it did it again.. lol it should say & times but these two together
 
Old 03-05-2003, 06:18 PM   #4
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
You've declared times as a pointer to a pointer. A 2D array is a 1D array of pointers, each pointing to 1D arrays (if I remember correctly). So unless gtk_signal_connect is expecting a char** as its fourth argument... passing &amp;times won't work.

Not sure what to tell you about how to fix it, though. Hopefully this gives you a place to start.

p.s. to type an ampersand with stuff following it, use &amp;amp;

Last edited by wapcaplet; 03-05-2003 at 06:20 PM.
 
Old 03-06-2003, 05:08 PM   #5
JStew
Member
 
Registered: Oct 2002
Location: North Atlanta
Distribution: LFS
Posts: 229

Original Poster
Rep: Reputation: 30
nm... i eventually found the error but your information did help a lot.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
passing arg 3 of `pthread_create' from incompatible pointer type wallwaters Programming 8 03-08-2010 01:46 AM
What is the warning: passing arg 3 of `pthread_create' from incompatible pointer type wallwaters Linux - Software 3 06-01-2005 08:30 AM
How does one surpress incompatible pointer type warnings? tonyfreeman Programming 1 08-18-2004 06:06 PM
curl "incompatible pointer type" while making PHP basse- Linux - Software 2 04-15-2004 10:21 AM
Installing Wine - incompatible pointer type orange400 Linux - Software 1 03-03-2003 12:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration