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 Used but not defined

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



Joined: 31 Jul 2012
Posts: 8

View user's profile Send private message

Function Used but not defined
PostPosted: Tue Jul 31, 2012 10:53 am     Reply with quote

Code:


/* Function declarations ******************************************************/
void setup_io(void);         // Sets up all I/O ports.
void start_rtcc(void);      // Sets up the rtcc counter.
void convert(void);         // Convert 2 pendant data values to 1 long.
void check_input(void);      // Enforces buttons pressed follow rules.
void motor_timers(void);   // Sets "change of direction" timers.
void process_state(void);   // Determines outputs for running motors.
void rtcc_isr(void);         // Interrupt service routine.
void make_it_so(void);     // Output to motors.

// Main ***********************************************************************

main() {
   setup_io();
   start_rtcc();

   while(TRUE) {
      if(go_thous){         // This variable set in isr.
         go_thous = 0;

         check_input();
         motor_timers();
         process_state();
         make_it_so();
      }
   }
return 0;
}

// Function definitions ********************************************************

setup_io() {
   set_tris_b(248);            // 1-input, 0-output. All out.
   port_b_pullups(TRUE);      // Use internal pullups.
   output_high(G);         // Turns off outputs.
   output_low(SRCLR);    // Clear input register.
   output_high(SRCLR);     // Input register back on.
   output_low(SRCK);     // Set clock input low.
   output_low(RCK);      // Set sr clock low.
   output_low(SIN);
return 0;
}



Why would I get this error


"Function used but not defined: ... setup_io 61 4013 setup_io SCR=1703
1 Errors, 0 Warnings."

Thanks for any help. It is greatly appreciated
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Tue Jul 31, 2012 11:59 am     Reply with quote

Change your definition for setup_io() to match the declaration:

Code:
void setup_io(void) {
   ...
}


See if that clears the error.
beeson76



Joined: 31 Jul 2012
Posts: 8

View user's profile Send private message

PostPosted: Tue Jul 31, 2012 12:42 pm     Reply with quote

I already tried that and it didnt seem to work. I moved the definitions before them being declared in main() and at this point in time, I am not getting the errors. Whether they come back or not I have no idea, but now I am getting the error:

*** Error 165 "C:\Programming Folder\PDDC PCS Project\PCS-RL.c" Line 518(10,14): No overload function matches

I am getting 5 of these errors in main().

Any help?Smile
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Jul 31, 2012 2:09 pm     Reply with quote

Code:

// DEFINE all these other global vars or no will compile either

void setup_io(void ) {
   set_tris_b(248);            // 1-input, 0-output. All out.
   port_b_pullups(TRUE);      // Use internal pullups.
   output_high(G);         // Turns off outputs.
   output_low(SRCLR);    // Clear input register.
   output_high(SRCLR);     // Input register back on.
   output_low(SRCK);     // Set clock input low.
   output_low(RCK);      // Set sr clock low.
   output_low(SIN);
   return; 
}

main() {
   setup_io();
   start_rtcc();
   while(TRUE) {
 
     if(go_thous){         // This variable set in isr.
         go_thous = 0;
         check_input();
         motor_timers();
         process_state();
         make_it_so();
      }
   }
 }
}


You have been trying to insert a function that RETURNS a VALUE==0.
ie: return 0.

The form that is preferred is above.

All you need is return;

and LOSE that return from main.
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Wed Aug 01, 2012 3:04 am     Reply with quote

It is vital to get declarations to match definitions, and actual usage in the functions to match the declaration.
So, if a function is defined as returning 'void', it must not have a 'return n', but only a 'return'. '0' is not 'void'.

Asmboy shows the difference here.

You don't even need a return at all, if the function doesn't need to exit anywhere except the end.

This has has always been fairly 'strict' in CCS, but has become more so as overloading support has been added....

Best Wishes
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