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

little change in input.c in example file gives error

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



Joined: 16 Dec 2013
Posts: 22

View user's profile Send private message

little change in input.c in example file gives error
PostPosted: Sat Dec 28, 2013 12:47 am     Reply with quote

hi i've compiled the input.c as here
Code:

#include<18f2550.h>
#include<stdlib.h>
#fuses NOWDT,HS,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,INVERT,parity=N,bits=8)
//#ifndef __INPUT_C__
//#define __INPUT_C__

#include <string.h>


#if defined(STREAM_SERIAL_INPUT)
   #define InputKbhit()    kbhit(STREAM_SERIAL_INPUT)
   #define InputPutc(c)    fputc(c, STREAM_SERIAL_INPUT)
   #define InputGetc()     fgetc(STREAM_SERIAL_INPUT)
#else
   #define InputKbhit()    kbhit()
   #define InputPutc(c)    putc(c)
   #define InputGetc()     getc()
 
#endif

unsigned int8 gethex1() {
   char digit;

   digit = InputGetc();

   InputPutc(digit);

   if(digit<='9')
     return(digit-'0');
   else
     return((toupper(digit)-'A')+10);
}

unsigned int8 gethex() {
   unsigned int8 lo,hi;

   hi = gethex1();
   lo = gethex1();
   if(lo==0xdd)
     return(hi);
   else
     return( hi*16+lo );
}

void get_string(char* s, unsigned int8 max) {
   unsigned int8 len;
   char c;

   max-=2;
   len=0;
   do {
     c=InputGetc();
     if(c==8) {  // Backspace
        if(len>0) {
          len--;
          InputPutc(c);
          InputPutc(' ');
          InputPutc(c);
        }
     } else if ((c>=' ')&&(c<='~'))
       if(len<=max) {
         s[len++]=c;
         InputPutc(c);
       }
   } while(c!=13);
   s[len]=0;
}

#ifdef _STRING
void get_stringEdit(char* s, unsigned int8 max) {
   unsigned int8 len;
   char c;

   len = strlen(s);

   if (len)
   {
     #if defined(STREAM_SERIAL_INPUT)
      fprintf(STREAM_SERIAL_INPUT, "%s", s);
     #else
      printf("%s", s);
     #endif
   }

   max-=2;

   do {
     c=InputGetc();
     if(c==8) {  // Backspace
        if(len>0) {
          len--;
          InputPutc(c);
          InputPutc(' ');
          InputPutc(c);
        }
     } else if ((c>=' ')&&(c<='~'))
       if(len<=max) {
         s[len++]=c;
         InputPutc(c);
       }
   } while(c!=13);
   s[len]=0;
}
#endif

// stdlib.h is required for the ato_ conversions
// in the following functions
#ifdef _STDLIB
signed int8 get_Int8(void)
{
  char s[5];
  signed int8 i;

  get_string(s, sizeof(s));

  i=atoi(s);
  return(i);
}

#ifdef _STRING
signed int8 get_Int8Edit(signed int8 old)
{
  char s[5];
  signed int8 i;

  sprintf(s, "%d", old);
  get_stringEdit(s, sizeof(s));

  i=atoi(s);
  return(i);
}
#endif

signed int16 get_Int16(void)
{
  char s[7];
  signed int16 l;

  get_string(s, sizeof(s));
  l=atol(s);
  return(l);
}

#ifdef _STRING
signed int16 get_Int16Edit(signed int16 old)
{
  char s[7];
  signed int16 l;

  sprintf(s, "%ld", old);

  get_stringEdit(s, sizeof(s));
  l=atol(s);
  return(l);
}
#endif

signed int32 get_Int32(void)
{
  char s[12];
  signed int32 l;

  get_string(s, sizeof(s));
  l=atoi32(s);
  return(l);
}

#ifdef _STRING
signed int32 get_Int32Edit(signed int32 old)
{
  char s[12];
  signed int32 l;

  sprintf(s, "%ld", old);

  get_stringEdit(s, sizeof(s));
  l=atoi32(s);
  return(l);
}
#endif

float get_float() {
  char s[20];
  float f;

  get_string(s, 20);
  f = atof(s);
  return(f);
}

#ifdef _STRING
float get_floatEdit(float old) {
  char s[20];
  float f;

  sprintf(s, "%f", old);

  get_string(s, 20);
  f = atof(s);
  return(f);
}
#endif

#if defined(__PCD__)
   #define get_int()       get_Int16()
   #define get_intEdit()   get_Int16Edit()
   #define get_long()      get_Int32()
   #define get_longEdit()  get_Int32Edit()
#else
   #define get_int()       get_Int8()
   #define get_intEdit()   get_Int8Edit()
   #define get_long()      get_Int16()
   #define get_longEdit()  get_Int16Edit()
#endif

#endif   //_STDLIB

#endif   //__INPUT_C__//error high lights here

The error is line 274[2,7] expecting function name
Can you tell me how to fix this ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Dec 28, 2013 12:57 am     Reply with quote

You have no main() function. That's the reason.

Also, don't try to compile CCS driver files as a "program". They are
intended to be added to your main program with an #include statement.
Also, in the general case, do not edit CCS driver files.
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