View previous topic :: View next topic |
Author |
Message |
pic_user
Joined: 25 Aug 2005 Posts: 16
|
Why am I getting function definition different from previous |
Posted: Thu Aug 25, 2005 10:50 pm |
|
|
Why am I getting error(29): function definition different from previous definition wait_dly Param#3
#include <16f877a.h>
#DEFINE FIRST_VAL 100
#DEFINE SECOND_VAL 200
/************************************************/
#FUSES HS, NOWDT, NOPROTECT, PUT
/************************************************/
void wait_dly ( wait_val, wait_cnt)
unsigned long int wait_cnt,wait_val;
unsigned long int i, delay = 0;
{
set_timer1(0);
for(i=0; i = wait_val*2 ; i++)
{
while (delay < wait_cnt)
delay = get_timer1();
set_timer1(0);
}
}
/************************* MAIN ***********************/
void main()
{
while(1)
{
wait_dly(CHANGE_VAL,CHANGE_VAL);
}
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 25, 2005 11:35 pm |
|
|
You're using the original K&R style of function declarations from the
1978 edition of their book. You need to do it the modern way, like this:
Code: |
void wait_dly(unsigned long int wait_val, unsigned long int wait_cnt)
{
unsigned long int i, delay = 0;
set_timer1(0);
// etc.
}
|
|
|
|
pic_user
Joined: 25 Aug 2005 Posts: 16
|
Thanks for the help |
Posted: Fri Aug 26, 2005 6:20 pm |
|
|
Thanks for the help. As it turns out I had experimented and did what you suggest. I thought the way I did it was still valid C. It is true that I am using old books as I try to come up to C. |
|
|
|