pointer to a function

Hello all,

I have a program in C that I want to implement in Dynamic C. There is one part of the program:

typedef struct _tagCommandList
{
const char * code;
int (* fp) (char *, char *, char *, char *, int);
}CommandList;

That gives following errors:

line 69 : ERROR COF_ECHOSTR5.C : Missing character ‘;’.
line 69 : ERROR COF_ECHOSTR5.C : Syntax error - or garbage at end of program.
line 69 : ERROR COF_ECHOSTR5.C : Need function definition or declaration.
line 69 : ERROR COF_ECHOSTR5.C : Missing character ‘;’.
line 69 : ERROR COF_ECHOSTR5.C : previously defined.
line 69 : ERROR COF_ECHOSTR5.C : Bad declaration: ‘,’ ‘;’ or ‘=’ expected.
line 69 : ERROR COF_ECHOSTR5.C : Illegal symbol name ‘’.
line 69 : ERROR COF_ECHOSTR5.C : Syntax error - or garbage at end of program.
line 69 : ERROR COF_ECHOSTR5.C : Need function definition or declaration.
line 69 : ERROR COF_ECHOSTR5.C : Missing character ‘;’.
line 69 : WARNING COF_ECHOSTR5.C : char is a keyword and should not be used as an identifier.
line 69 : WARNING COF_ECHOSTR5.C : char is a keyword and should not be used as an identifier.

The line that concretely gives so many problems is:

int (* fp) (char *, char *, char *, char *, int);

It seems that Dynamic C does not like pointers to functions but I have been looking in TN203 “Porting a Program to Dynamic C” and does not say anything about it.

Any idea on how to solve this problem is welcome.

Thanks in advance to everybody,

Leirert

Try the declaration without the arguments in the function pointer like below:

struct { char c; int *p(); } s;

int foo(int x)
{
return 1;
}

void main (void)
{
s.p = foo;

s.p(0);
}

This compiles quite nicely. Good luck!

Thanks a lot for your quick response “dwstojan”. I have done the declaration with no arguments and it does not give any error. Let’s see now if it works fine.

Thanks again.