|
|
View previous topic :: View next topic |
Author |
Message |
shaunak_s
Joined: 04 Jan 2011 Posts: 3
|
Help using #inline |
Posted: Tue Jan 04, 2011 12:38 am |
|
|
We are using PIC16F886 in our project and developing code in C.
Please can you let me know how to use #inline pre-processor directive? I have used it in the following fashion
Code: |
#inline
void Send_Data_Pattern( void )
{
#ifdef COMMON_ANODE
nCS0_High(); //Pin B4 nCS0 high by default
nCS1_High(); //Pin B5 nCS1 high by default
#else
nCS0_Low(); //Pin B4 nCS0 low by default
nCS1_Low(); //Pin B5 nCS1 low by default
#endif
output_c( Display_Data[Decode_Select] ); //Update the Data lines
if( Decode_Select == 1 ) {
nCS1_High(); //Pin B5 nCS1 high by default
}
else {
nCS0_High(); //Pin B4 nCS0 high by default
}
//PORTB &= ( 0xF3|Decode_Select );
Decode_Select++; //Shift to select the next display module
if( Decode_Select >= MAX_DIGITS ) {
Decode_Select = 0;
}
enable_interrupts( GLOBAL );
}
|
And I get the following error
Quote: |
*** Error 166 "7segment.c" Line 173(1,2): Invalid overload function Send_Data_Pattern
*** Error 28 "7segment.c" Line 179(15,16): Expecting an identifier |
Please can you help us out? Thanks very much. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Tue Jan 04, 2011 2:58 am |
|
|
Problems have little to do with #inline....
First, says you have another declaration somewhere, that differs from this one. This one could be caused by 'inline', since if you have a function prototype, the prototype, must _also_ have the inline directive.
The second, suggests that a value used in a call, is not defined 'for' this function. So I'd guess (possibly) that 'Display_Data', is not global, and is therefore not available in this function.
Really impossible to answer without seeing the definitions for everything used in this function, and the exact line numbers.
Best Wishes |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Tue Jan 04, 2011 3:27 am |
|
|
As one comment, it is _rarely_ worth using #inline.
The compiler _automatically_ 'inlines' functions, if they are small, and not called from a wide variety of diverse places. If the compiler doesn't automatically 'inline' a function, it implies it costs a lot in memory terms to have it inline. #separate, is therefore the more useful function, overriding the default behaviour, where putting the function inline, would lead to memory pages becoming overfull. Forcing 'inline', is very rarely needed.
Best Wishes |
|
|
shaunak_s
Joined: 04 Jan 2011 Posts: 3
|
|
Posted: Tue Jan 04, 2011 5:17 am |
|
|
Hi Ttelmah,
Actually Display_Data is defined global but it is static to the file. Secondly, I have not used inline when defining the function prototype so that may be the cause of the problem. Anyway, I have made headways without using inline and as you have also later suggested that using inline is not of much use, I think I will go with that.
Thanks very much for all the help.
Regards,
Shaunak |
|
|
|
|
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
|