CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

FUNCTION POINTERS

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Michaelc



Joined: 18 Nov 2003
Posts: 14
Location: Ireland

View user's profile Send private message

FUNCTION POINTERS
PostPosted: Thu Mar 04, 2004 9:38 am     Reply with quote

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

View user's profile Send private message

Function Pinters
PostPosted: Thu Mar 04, 2004 9:45 am     Reply with quote

From the CCS version lisitng at http://www.ccsinfo.com/versions.shtml:

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
PostPosted: Thu Mar 04, 2004 9:48 am     Reply with quote

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.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group