Thomas O
Thomas O

Reputation: 6220

Function pointers in C

The following code (a function prototype):

void parse_ini(FSFILE *fp, void(*secFunc)(char*), void(*varFunc)(char*, char*));

presents errors when compiled:

util\setup.c:38: error: syntax error before '*' token
util\setup.c:38: error: 'parse_ini' declared as function returning a function
util\setup.c:38: error: syntax error before 'void'
util\setup.c:50: error: syntax error before '*' token

What is causing this? Using MPLAB C30, which is a version of GCC v3.23 for PIC24F/dsPIC 16-bit microcontrollers.

Upvotes: 0

Views: 932

Answers (2)

t0mm13b
t0mm13b

Reputation: 34592

try this

typedef void (*varfuncptr)(char *, char*);
typedef void (*secfuncptr)(char *);

void parse_ini(FSFILE *fp, secfuncptr *secFunc, varfuncptr *varFunc);

Upvotes: 2

Michael Burr
Michael Burr

Reputation: 340208

I'd guess that you haven't included a header that declares/defines FSFILE.

Upvotes: 7

Related Questions