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 support@ccsinfo.com

function pointers are not ready for prime time

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



Joined: 19 Sep 2003
Posts: 3

View user's profile Send private message

function pointers are not ready for prime time
PostPosted: Fri Sep 19, 2003 1:15 am     Reply with quote

So I just wasted most of a day trying to get function pointers to work in CCS. My experience is that the implementation is incredibly buggy.

(I'm using 3.173 -- haven't updated to 3.178 because the release notes don't suggest that these poblems have been fixed, and last time I updated on a whim I lost another day's work.)

Here's an example of what I mean by buggy:

The following compiles fine:
Code:

#include <18f452.h>
   
 typedef int1 bool;
 typedef bool (*FuncFoo) ();
   
void main() {
}


The following code (functionally identical) fails to compile with error:
Error[38] ... This type can not be qualified with this qualifier
Code:

#include <18f452.h>
   
typedef int1 (*FuncFoo) ();

void main() {
}


Does this sort of thing drive anyone else mad?

-bart
bartholomew



Joined: 19 Sep 2003
Posts: 3

View user's profile Send private message

another example...
PostPosted: Fri Sep 19, 2003 1:25 am     Reply with quote

Here's another example of function pointer bugginess.

The following compiles fine:
Code:
#include <18f452.h>

typedef int (*FuncFoo) ();

int foo() {
    // do nothing
}
   
void main() {
    FuncFoo someFunction;
    someFunction = foo;
           
    (*someFunction)();
}


However if I comment out the last line (*someFunction)(); I
get:
Error[44] ... Internal Error - Contact CCS LABEL SCR = 356
and if I leave it commented out but make someFunction global, I get:
Error[44] ... Internal Error - Contact CCS LABEL SCR = 354

Anyway, generally CCS is happy to assign foo to someFunction, but what if the assignee is part of a struct?

Code:
#include <18f452.h>

typedef int (*FuncFoo) ();

int foo() {
    // do nothing
}

struct {
    FuncFoo someFunction;
} gFuncStruct;

void main() {
    gFuncStruct.someFunction = foo;
}


In this case, CCS errors out with
Error[117] ... Improper use of a function identifier

What does this mean?

-bart
bartholomew



Joined: 19 Sep 2003
Posts: 3

View user's profile Send private message

third example of function pointer bugginess...
PostPosted: Fri Sep 19, 2003 1:33 am     Reply with quote

Here's my last example for the day of why CCS's function pointer implementation is not ready for prime time.

The following code compiles fine:
Code:
#include <18f452.h>

typedef void (*FuncNothing) (char c);
typedef char (*FuncReceive) ();

FuncNothing sFuncNothing;

void nothing(char c) {
    // do nothing
}

void neverCalled() {
    sFuncNothing = nothing;
}

void main() {
}


Yes I know that it is pretty pointless code, but it is analogous to a heap of code I just wrote. Anyway, suppose I swap the order of the two typedefs, so the code is as follows:
Code:
typedef char (*FuncReceive) ();
typedef void (*FuncNothing) (char c);


When I do the above, I get the error:
Error[118] ... Invalid type conversion

Can you imagine how frustrating it is to track down bugs when the order of typedefs matters to CCS? Has anyone put together a list of what works and what doesn't with function pointers?

Downloading MPLABŪ C18 free demo now to see if Microchip do it any better...

-bart
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

View user's profile Send private message Send e-mail

PostPosted: Fri Sep 19, 2003 7:52 am     Reply with quote

I thought pointers to functions were beta. In fact, I don't think they've even been documented yet.
Guest








PostPosted: Thu Jan 15, 2004 10:15 am     Reply with quote

after ver 3.160 function pointers are supported
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 15, 2004 10:47 am     Reply with quote

You're talking about this comment:
"3.160 Pointers to functions are now supported"
on the versions page, http://www.ccsinfo.com/versions.shtml

For your information, just because CCS announces something
there, it doesn't mean that it's fully tested. It means that
they've newly added it as a feature. It may, and often does,
have bugs for a while.
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

View user's profile Send private message Send e-mail

PostPosted: Thu Jan 15, 2004 12:03 pm     Reply with quote

Yes, beta.

Support added, not documented. Also "supported added" in the version update page doesn't mean full support added.

Progress has to start somewhere.

You've put a lot of work and thought into this, please e-mail everything to CCS - including source code, .lst file, and description of each problem.
h
Guest







PostPosted: Thu Jan 22, 2004 1:42 pm     Reply with quote

so, when do you think function pointers will be ready for everyday use?
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