IAM using pcw ver3.28 and i am attempting to use funcion pointers so that
i can get the address of different functions. The help files tell me i can't use function pointers but i've being told that it can and it does compile the declaration of a function pointer. Standard ansi c will compile the following:
void dummy(void);
main()
{
void (*ptrfunction)(); //declaration of function pointer
ptrfunction = dummy; //assigment
}
void dummy(void)
{
int i;
i++;
}
However with the picc compiler it will compile the declaration unlike previous compilers but wont compile the assignment. It will give me the error IMPROPER USE OF FUNCTION IDENTIFIER. If i change the assignment to
ptrfunction = dummy();
It will compile it perfectly, but it doesnt work.
Where am i going wrong or what is the deal with function pointers in PICC.
Thanks
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
3.157 The compiler can now generate COFF debug files
3.158 A hang problem (since 3.157) is fixed
3.158 A new format for the help file (.CHM) has been released
3.160 Pointers to functions are now supported <*****************
3.160 Examples updated to use more modern chips
3.160 PCW IDE improvments incorporated
3.160 Some COFF debug file problems are resolved
3.162 More PCW IDE improvments incorporated
Ttelmah Guest
Re: FUNCTION POINTERS
Posted: Thu Mar 04, 2004 9:48 am
Michaelc wrote:
IAM using pcw ver3.28 and i am attempting to use funcion pointers so that
i can get the address of different functions. The help files tell me i can't use function pointers but i've being told that it can and it does compile the declaration of a function pointer. Standard ansi c will compile the following:
void dummy(void);
main()
{
void (*ptrfunction)(); //declaration of function pointer
ptrfunction = dummy; //assigment
}
void dummy(void)
{
int i;
i++;
}
However with the picc compiler it will compile the declaration unlike previous compilers but wont compile the assignment. It will give me the error IMPROPER USE OF FUNCTION IDENTIFIER. If i change the assignment to
ptrfunction = dummy();
It will compile it perfectly, but it doesnt work.
Where am i going wrong or what is the deal with function pointers in PICC.
Thanks
Limited 'pointer to function' support exists _from V3.160 onwards_. You say version 3.28. If this is 3.028, then the ability doesn't yet exist.
There is a list on the CCS website, that gives the changes between versions.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum