LinuxQuestions.org
Review your favorite Linux distribution.
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
 
LinkBack Search this Thread
Old 08-08-2006, 12:49 PM   #1
websinger
Member
 
Registered: Jul 2003
Location: Virginia
Distribution: Debian -sid
Posts: 34

Rep: Reputation: 15
C: Function declaration woes


I'm trying to get some mouse-ishness into
some of my programs and was investigating
GPM - I copied this code from a web site and tried to
compile and got errors can anyone give me some insight?



jeff@GONDOR:~/arc/c++$ cat mtest1.c
#include <stdlib.h>
#include <stdio.h>
#include <gpm.h>
int my_handler( Gpm_event *event , void *data ){
printf("Event type : %d at x-%d y-%d\n",
event->type, event->x, event-y);
return 0;
}
int main(){
Gpm_Connect conn;
int c;
conn.eventMask = ~0;
conn.defaultMask = 0;
conn.minMod = 0;
conn.maxMod = ~0;
if(Gpm_Open(&conn, 0) == -1)
printf("Cannot connect to mouse server\n");
gpm_handler = my_handler;
while((c = Gpm_Getc(stdin)) != EOF) printf("%c", c);
Gpm_Close();
return 0;
}
jeff@GONDOR:~/arc/c++$ gcc -lpgm -omtest1 mtest1.c
mtest1.c:4: error: expected ')' before '*' token
mtest1.c: In function 'main':
mtest1.c:18: error: 'my_handler' undeclared (first use in this function)

Thanks,
Jeff
 
Old 08-08-2006, 12:52 PM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by websinger
gpm_handler = my_handler;
That's where the problem is, you forgot the brackets and the arguments. Edit: also, it appears you haven't put what type gpm_handler should be (presumably an int, since that's what my_handler() returns).

Edit: well, those are certainly problems. Not sure what line 4 is about, though :/.

Last edited by Nylex; 08-08-2006 at 01:22 PM.
 
Old 08-08-2006, 01:48 PM   #3
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
could it be that Gpm_event is actually Gpm_Event
 
Old 08-08-2006, 02:40 PM   #4
websinger
Member
 
Registered: Jul 2003
Location: Virginia
Distribution: Debian -sid
Posts: 34

Original Poster
Rep: Reputation: 15
Yes !

That was the Problem.
Thanks

Jeff
 
Old 08-08-2006, 02:56 PM   #5
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
youre welcome.

please use code tags next time.
 
  


Reply

Tags
programming


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
warning: implicit declaration of function liguorir Linux - Software 5 10-22-2012 03:20 PM
implicit declaration of function 'getdelim' MicahCarrick Programming 2 05-02-2005 11:03 AM
Unintelligible declaration of signal function Nerox Programming 4 08-11-2004 04:45 PM
Arguments in PHP function declaration Parksy Programming 5 07-04-2004 04:22 PM
Problem with function declaration Linh Programming 3 04-26-2004 04:58 PM


All times are GMT -5. The time now is 03:07 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration