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?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
emh203@psu.edu



Joined: 05 May 2006
Posts: 2

View user's profile Send private message

Function Pointers?
PostPosted: Fri May 05, 2006 4:01 pm     Reply with quote

Does CCS allow the use of function pointers? For example, I want to pass a function pointer in another function like so (standard C):

unsigned char RegisterMessageDelegate(int (*MessageDelegate)(unsigned char *,unsigned short));

The compiler will not allow this. Is there another way of using function pointers with this compiler?

Thanks,
ELi
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Fri May 05, 2006 8:02 pm     Reply with quote

It use to say just use a switch statment.
But now it looks like you can do it the ansi C way.
http://www.ccsinfo.com/faq.php?page=pointer_to_function
emh203@psu.edu



Joined: 05 May 2006
Posts: 2

View user's profile Send private message

No, not pointers to variables, pointers to Function
PostPosted: Mon May 08, 2006 7:26 am     Reply with quote

QSORT Only appears to be a standard pointer (for memory/variables). What I need is support for pointers to Functions.

-ELi
Ttelmah
Guest







PostPosted: Mon May 08, 2006 7:38 am     Reply with quote

No, QSORT, uses pointers to functions, not just to values. There is a function 'ascending', and a function 'descending', and these are passed to the qsort function as the 'compare' item. Look again.

Best Wishes
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Mon May 08, 2006 7:59 am     Reply with quote

You can also use the search feature to find your answers. Here is a snippet from an old post

Code:

// Typedef for our function pointer
typedef int (*pFunc)(void);


int myfunction(void)
{
  return (1);
}

void main()
{
  int i;
  pFunc ptrtofunc;

  // Dummy initialization to keep the compiler from complaining
  ptrtofunc = myfunction;

  // Call the function
  i=(*ptrtofunc)();

  while( TRUE )
  {
  }
}
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