LinuxQuestions.org
Visit Jeremy's Blog.
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 07-28-2011, 04:31 AM   #1
m.dehghan
LQ Newbie
 
Registered: Jul 2011
Posts: 1

Rep: Reputation: Disabled
invalid conversion


I am writing a function, and I'm getting the error "invalid conversion from 'void(*)(u_char* , u_int , void* )' to 'void(*)(tuple*,u_char*,u_int,void*)
Any help would be appreciated.
 
Old 07-28-2011, 05:18 AM   #2
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,522

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
You haven't supplied enough information for anyone to truly point out the error in your code. However, below is a sample program that perhaps you can use to figure out where you went wrong with your programming.
Code:
#include <stdio.h>

typedef unsigned int  u_int;
typedef unsigned char u_char;

typedef struct
{
  u_int x, y, z;
} tuple;

typedef void (*Function)(tuple*, u_char*, u_int, void*);

void myFunction(tuple* param1, u_char* param2, u_int param3, void* param4)
{
   printf("I'm here!\n");
}

void otherFunction(Function f)
{
   tuple t;
   u_char uc;
   u_int  ui;
   void*  v;

   f(&t, &uc, ui, v);
}

int main(void)
{
   // passing function to another function
   otherFunction(&myFunction);

   // declaring a function pointer
   Function f = &myFunction;

   tuple t;
   u_char uc;
   u_int  ui;
   void*  v;

   f(&t, &uc, ui, v);

   return 0;
}
 
  


Reply


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
invalid conversion from `int*' to `socklen_t*' r350 Programming 5 10-02-2011 05:34 PM
Invalid conversion from bool fsshl Programming 3 07-19-2011 06:42 PM
Invalid conversion from ‘char’ to ‘packet_t’ mcpoon Programming 4 05-25-2010 03:55 AM
error: invalid conversion from `void*' to `char*' pstevens57 Programming 2 03-10-2009 01:57 PM
invalid conversion from `char' to `const ch predatorz Programming 3 11-15-2008 01:00 PM


All times are GMT -5. The time now is 02:48 PM.

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