![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
/dev/human
Joined: 01 Sep 2008 Posts: 19 Location: Earth / Europe / Germany
|
Function Prototype causes "Expecting an identifier" |
Posted: Mon Sep 01, 2008 2:38 am |
|
|
Hi Folks,
I can't figure out what's causing the "Expecting an identifier" error in my code. Using MS Visual C++ compiler my world was looking fine.
There is a prototype of the function in the header file
Code: | char LCDprintf (unsigned char, char [], float);
unsigned char LCD_RW_IO (unsigned char, unsigned char, unsigned char);
void LCD_Init (); |
And the the module function code is this
Code: | char LCDprintf (unsigned char Line, char String [], float Value) {
char LCDstring[MaxLCDcolumn+4]; // Make sure string is long enough including some formating
int i;
char Error = 0;
strncpy (LCDstring, String, sizeof (LCDstring)); // Truncate string to max columns of LCDstring
LCDstring [sizeof (LCDstring) - 1] = '\0'; // Add string terminator at the end
sprintf (LCDstring, LCDstring, Value); // Insert the "value" according to format information
LCDstring [MaxLCDcolumn] = '\0'; // Make sure to have number of characters fitting on the LCD row
for (i = strlen (LCDstring); i < MaxLCDcolumn; i++) { // Fill up if necessary
LCDstring [i] = ' ';
}
#if MaxLCDcolumn == 16 & MaxLCDrow == 3 // Next lines only for 16 x 3 line display
if (Line >= 1 && Line <= 3) { // Check for valid row number
LCD_RW_IO (((Line - 1) * 16) | 0x80, Write, Command); // Set display curser to line
#ifdef PC_Debug
printf ("Data sent to LCD: _");
#endif
for (i = 0; i < MaxLCDcolumn; i++) { // Write charaters of one line to display
LCD_RW_IO (LCDstring [i], Write, Data);
#ifdef PC_Debug
printf ("%c", LCDstring [i]);
#endif
}
#ifdef PC_Debug
printf ("_\n");
#endif
}
else {
Error = Illegal_Line;
}
#endif
return Error;
} |
Thanks in advance for help |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Mon Sep 01, 2008 3:21 am |
|
|
The prototypes need to have the variable names as well. So the prototype for the first function, becomes:
char LCDprintf (unsigned char Line, char String [], float Value);
This is a difference between the original C, and latter implementations. Originally 'C', didn't support prototypes at all, but allowed them in the form that CCS implements. Latter, ones without variable names, were added to ANSI C, and this has continued since.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
/dev/human
Joined: 01 Sep 2008 Posts: 19 Location: Earth / Europe / Germany
|
Solved |
Posted: Mon Sep 01, 2008 3:29 am |
|
|
Thanks, I wasn't aware of this. It's working fine now (at this place). although I'm wondering, why it's happening only with this prototype. The other ones are compiled neatly. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|