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

Can’t assign pointer to a library function

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



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

Can’t assign pointer to a library function
PostPosted: Wed Jul 23, 2008 6:09 am     Reply with quote

Colleagues,

I was trying to make a generic set_pwmX_duty(x, duty) function with a table of pointers: {set_pwm1_duty, set_pwm2_duty, …}. Unfortunately, I’m getting a compile time error:

Code:

typedef void (*fptypeSetPWMDuty)(int16 iPWM);   // pointer to the set_pwm12345_duty() function
typedef struct       // structure describing a channel
{
   ...
   fptypeSetPWMDuty  fpSetPWMDuty;  // pointer to the set_pwmX_duty() function
   ...
}

...

   g_sChannels[0].fpSetPWMDuty = set_pwm1_duty;    // compile-time error: Undefined identifier   set_pwm1_duty
   set_pwm1_duty(255);    // at the same time, this line of dummy code compiles just fine


PCWH 4.071 PIC18F4525

Cheers
- Nick
_________________
Read the label, before opening a can of worms.
Ttelmah
Guest







PostPosted: Wed Jul 23, 2008 8:03 am     Reply with quote

You will almost certainly find that set_pwmX_duty, is not really a 'function', but possibly a simple macro expansion. You will almost certainly have to put it into a 'wrapper' function, to allow a pointer to be generated.
Simple operations like this, which only transfer bytes into specific registers, with some basic manipulation on the way, are almost invariably not functions.

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