WhyWhy
Member level 4
- Joined
- Mar 18, 2013
- Messages
- 68
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Activity points
- 1,779
Some compilers will assume a default and give a warning rather than error - check the compile warnings.
Keith
//**********************************************************************************************************
// Hitech C
//**********************************************************************************************************
#include <pic.h>
//**********************************************************************************************************
__CONFIG ( FOSC_XT & WDTE_OFF & PWRTE_OFF & CP_OFF );
//**********************************************************************************************************
void delay()
{
unsigned int i;
for (i =0; i<20000; i++)
{
NOP();
}
}
//**********************************************************************************************************
void main()
{
TRISB = 0;
PORTB = 0;
while(1)
{
CLRWDT();
RB0=0;
delay();
RB0=1;
delay();
}
}
//**********************************************************************************************************
//**********************************************************************************************************
// Hitech C
//**********************************************************************************************************
#include <pic.h>
//**********************************************************************************************************
__CONFIG ( FOSC_XT & WDTE_OFF & PWRTE_OFF & CP_OFF );
//**********************************************************************************************************
#ifndef _XTAL_FREQ
// Unless already defined assume 4MHz system frequency
// This definition is required to calibrate __delay_us() and __delay_ms()
#define _XTAL_FREQ 4000000
#endif
//**********************************************************************************************************
void main()
{
TRISB = 0;
PORTB = 0;
while(1)
{
CLRWDT();
RB0=0;
__delay_ms(200);
RB0=1;
__delay_ms(200);
}
}
//**********************************************************************************************************
But How could the program running correctly by taking i as a variable??
Hi i didnt change any settings... It could declare a function, most compilers will do, but how could a variable been declared...i should be a variable - an 'int'. Some compilers will assume undeclared ones are 'int'. XC16 does that if you don't include a function prototype but it does warn you. You can probably change the settings so it gives an error instead.
Keith
My variable is temp or something and provide same result!!!
In my compiler has error "undefined identifier "i"", if not declare a variable!!!
And post is #6!!!
The compiler generate hex???
it's not your compiler generate undefined identifier "i" bro my compiler is also generated same message but question is why WHYWHY said program run successfully ????.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?