473,326 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

question about function pointer

Hi all

passing argument of "lib_init_terminal" from incompatible pointer type

invoke code slice
=================
lib_init_terminal (&sys_init_signals);
prototype
=========
void sys_init_signals (void);
int lib_init_terminal (void *ptr_sys_init_signals(void))
{
(*ptr_sys_init_signals)();
}

where 's the mistake?


thank you very much

your key9
Sep 16 '06 #1
1 1115
key9 wrote:
Hi all

passing argument of "lib_init_terminal" from incompatible pointer type

invoke code slice
=================
lib_init_terminal (&sys_init_signals);
prototype
=========
void sys_init_signals (void);
int lib_init_terminal (void *ptr_sys_init_signals(void))
{
(*ptr_sys_init_signals)();
}

where 's the mistake?
Why is it so hard for people to post compilable code? Surrounding your
call with 'int main(void) {' and '}' would have been easier for you that
those stupid tags with equal-sign underlining.

The answer:

void sys_init_signals(void);

#if 0
/* your illegal form, which claims ptr_sys_init_signals returns
a pointer-to-void */
int lib_init_terminal(void *ptr_sys_init_signals(void))

/* a form that works */
int lib_init_terminal(void (*ptr_sys_init_signals) (void))
#endif
/* and a cleaner form that works */
int lib_init_terminal(void ptr_sys_init_signals(void))
{
(*ptr_sys_init_signals) ();
return 0; /* added. You claim lib_init_terminal
returns an int, but you don't return
one. */
}

int main(void)
{
lib_init_terminal(&sys_init_signals);
return 0;
}
Sep 16 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Asif | last post by:
Hi there, I have been trying to understand the behaviour of char (*pfn)(null) for a couple of days. can some body help me understand the behaviour of char (*pfn)(null) in Visual C++ environment?...
3
by: Bryan Parkoff | last post by:
Do C/C++ Compiler allow function to contain more than 8 parameters? I checked MS Visual C++ 6.0 that it can only limit 8 parameters, but most C/C++ Compiler can limit maximum 256 parameters. Can...
4
by: anonymous | last post by:
Thanks your reply. The article I read is from www.hakin9.org/en/attachments/stackoverflow_en.pdf. And you're right. I don't know it very clearly. And that's why I want to understand it; for it's...
1
by: rahul8143 | last post by:
hello, In kernel source code there is ip_fragment.c file my question is regarding pointer function and casting for that look at required snippet from that file There is structure defined for...
14
by: John Gerrard | last post by:
Hi, my name is John and this is my first posting to comp.lang.c. I am learning C. I am a high school student with interest in programming. I have a copy of "The C programming language second...
4
by: Andreas Klimas | last post by:
hello, no many words, I will start with an example instead int foo(void *r) {...} void test(void) { int *x=0; foo(x); /* seems to me as valid */ }
14
by: streamkid | last post by:
i'm a learning newbie at c++... and i have the following question... reading some source code, i saw this: int function(const void * one, const void * two) { int var1, var2; var1 =...
33
by: jobo | last post by:
If I have the function: int f(int (*h)(int)) { return (*h)(13); } What exactly does (int (*h)(int)) do? So it's taking a pointer but what's with the two ints? Thanks.
28
by: junky_fellow | last post by:
Guys, Consider a function func(void **var) { /* In function I need to typecast the variable var as (int **) I mean to say, I need to access var as (int **) }
2
by: Giorgos Keramidas | last post by:
On Sun, 05 Oct 2008 18:22:13 +0300, Giorgos Keramidas <keramida@ceid.upatras.grwrote: My apologies. I should have been less hasty to hit `post'. If showtext() is passed a null pointer, it may...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.