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 CCS Technical Support

Function Prototype causes "Expecting an identifier"

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



Joined: 01 Sep 2008
Posts: 19
Location: Earth / Europe / Germany

View user's profile Send private message

Function Prototype causes "Expecting an identifier"
PostPosted: Mon Sep 01, 2008 2:38 am     Reply with quote

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
Ttelmah
Guest







PostPosted: Mon Sep 01, 2008 3:21 am     Reply with quote

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
/dev/human



Joined: 01 Sep 2008
Posts: 19
Location: Earth / Europe / Germany

View user's profile Send private message

Solved
PostPosted: Mon Sep 01, 2008 3:29 am     Reply with quote

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.
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