Re: Pointers to functions in structures trubble!
- From: Ian Collins <ian-news@xxxxxxxxxxx>
- Date: Thu, 13 Jul 2006 16:13:01 +1200
addinall@xxxxxxxxxxxx wrote:
Ian Collins wrote:<snipped code>
addinall@xxxxxxxxxxxx wrote:
Ian Collins wrote:
What's the prototype for __life? Generally not a good idea to use '__'
at the beginning of a function name.
Yeah. I thought an earlier prblem may have been name duplication
so.....
I got it to compile by...
new_heartbeat->life = &__life ;
The & isn't requited and you realy should remove the double underscore
from your names. All identifiers starting with double underscore are
reserved.
So... it compiles and links without errors just on a simpleStar with a simple test case, like
cc t.c -o t
Try to run it
../t
Segmentation fault.
Something is stuffed and I think it may be me! ;-)
#include <stdio.h>
void f() { puts("hello\n"); }
struct X
{
void (*fn)();
};
int
main()
{
struct X x;
x.fn = f;
x.fn();
}
--
Ian Collins.
.
- Follow-Ups:
- Re: Pointers to functions in structures trubble!
- From: addinall
- Re: Pointers to functions in structures trubble!
- References:
- Pointers to functions in structures trubble!
- From: addinall
- Re: Pointers to functions in structures trubble!
- From: Ian Collins
- Re: Pointers to functions in structures trubble!
- From: addinall
- Re: Pointers to functions in structures trubble!
- From: Ian Collins
- Re: Pointers to functions in structures trubble!
- From: addinall
- Pointers to functions in structures trubble!
- Prev by Date: Re: Pointers to functions in structures trubble!
- Next by Date: Re: printf doubt
- Previous by thread: Re: Pointers to functions in structures trubble!
- Next by thread: Re: Pointers to functions in structures trubble!
- Index(es):
Relevant Pages
|