Discussion:
[Sdcc-user] function pointer inside a structure
Yigal Hochberg
2003-02-26 10:23:08 UTC
Permalink
Bernhard,

I think there is a problem in the sdcc compiler when function pointer
is used in a structure field.

In foo1() sdcc does not like the call to myabc.funcptr().

I get this error with sdcc.
================<< start quote ============================
cd f:/yigal/snmp.201/agent/
d:\sdcc\bin\sdcc -c --model-large t.c
t.c:34: warning: Functions called via pointers must be 'reentrant' to take arguments

Compilation finished at Wed Feb 26 07:16:28
================== end quote >>==============================

Any suggestion how to solve this?

Thank you.
--
- Yigal



#if !defined(SDCC)
#define reentrant
#endif

typedef int (Funcptr_t)(int x, int y, char *z) reentrant; /* function pointer type */

struct abc {
Funcptr_t *funcptr;
};

void
foo(int a,
int (*func_ptr)(int x, int y, char *z) reentrant, /* function pointer */
int b)
{

a = 5;
b = 5;
(*func_ptr)(a, b, "hello");
}

void
foo1(int a,
Funcptr_t *func_ptr,
int b)
{
struct abc myabc;

a = 5;
b = 5;
(*func_ptr)(a, b, "hello");

(*myabc.funcptr)(a, b,"hello"); /* sdcc does not like it */
}


/*
* Local Variables:
* cc: "d:\\sdcc\\bin\\sdcc"
* cc-flags: "-c --model-large"
* eval: (make-local-variable 'compile-command)
* eval: (setq compile-command (concat cc " " cc-flags " "
(file-name-nondirectory buffer-file-name)))
* End:
*/
Bernhard Held
2003-02-27 05:25:03 UTC
Permalink
Post by Yigal Hochberg
Bernhard,
Once again: I'm not your personal problem solver. Post your initial
questions to the list and never directly to me!

Bernhard
Yigal Hochberg
2003-02-27 10:09:02 UTC
Permalink
Hi Bernhard,

I am sorry if I bothered you. You helped me quite a bit and I thank
you very much for your kind replied. I just started working with sdcc
and did not have much knowledge about it as you have.

Thank you so much fro your help so far.

Regards,
Post by Bernhard Held
Post by Yigal Hochberg
Bernhard,
Once again: I'm not your personal problem solver. Post your initial
questions to the list and never directly to me!
Bernhard
--
- Yigal
Bernhard Held
2003-02-27 10:51:10 UTC
Permalink
Hi Yigal!
Post by Yigal Hochberg
I am sorry if I bothered you.
Ok, accepted. Let's return to constructive work.

Bernhard

Bernhard Held
2003-02-27 10:27:10 UTC
Permalink
Post by Yigal Hochberg
In foo1() sdcc does not like the call to myabc.funcptr().
I get this error with sdcc.
================<< start quote ============================
cd f:/yigal/snmp.201/agent/
d:\sdcc\bin\sdcc -c --model-large t.c
t.c:34: warning: Functions called via pointers must be 'reentrant' to take arguments
Compilation finished at Wed Feb 26 07:16:28
================== end quote >>==============================
Any suggestion how to solve this?
It's another bug :-(
You've again prepared a nice expample, so please file it at
http://sourceforge.net/tracker/index.php

Bernhard
Continue reading on narkive:
Loading...