View previous topic :: View next topic |
Author |
Message |
beeson76
Joined: 31 Jul 2012 Posts: 8
|
Function Used but not defined |
Posted: Tue Jul 31, 2012 10:53 am |
|
|
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: 1909
|
|
Posted: Tue Jul 31, 2012 11:59 am |
|
|
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
|
|
Posted: Tue Jul 31, 2012 12:42 pm |
|
|
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? |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Jul 31, 2012 2:09 pm |
|
|
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: 19537
|
|
Posted: Wed Aug 01, 2012 3:04 am |
|
|
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 |
|
|
|