|
|
View previous topic :: View next topic |
Author |
Message |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
Can’t assign pointer to a library function |
Posted: Wed Jul 23, 2008 6:09 am |
|
|
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
|
|
Posted: Wed Jul 23, 2008 8:03 am |
|
|
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 |
|
|
|
|
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
|