Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Problem in default arithmetic for ' i ' variable.

Status
Not open for further replies.

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
Hi guys,

I not set any arithmetic such as int,char or float for the ' i ' variable.When execute the program still the having delay function,so the default arithmetic for the i will be int,char or float ?

Untitled.png

Regards,
YY
 

Hi you are using which compiler?? no C compiler declares the variables by default, You have to mention it to be a variable. There is no way compiling this program without i being global variable...

Seeing at value of i compared with 20000 It shd be an int value..
 

is that your program run complete or not?
 

whare you have declare variable i?
 

HI Guys,

But the program is run successfully,that is the reason why i asking here...

Regards,
YY
 

put some different variable and test the result ?
 

redefine this variable and check wheather warning is there or not
and check the included file is same which one your checking.
 

Some compilers will assume a default and give a warning rather than error - check the compile warnings. You have not said which compiler.

Keith
 

Try this:

Code:
//**********************************************************************************************************
// 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();
		}
}
//**********************************************************************************************************

Or this

Code:
//**********************************************************************************************************
// 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);
		}
}
//**********************************************************************************************************
 
Last edited:

But How could the program running correctly by taking i as a variable??

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
 

hey Nagkiller i think u don't understand problem because problem is he does not declare any variable i in his code and then program successfully run . bro WhyWhy mentioned post no . # 5 and i also suggest put some different variable like j , k and try it run or not ?
 

My variable is temp or something and provide same result!!!

In my compiler has error "undefined identifier "i"", if not declare a variable!!!

My version of hitech is V9.83 pro!!!

And post is #6!!!

The compiler generate hex???
 
Last edited:

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
Hi i didnt change any settings... It could declare a function, most compilers will do, but how could a variable been declared...
 

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 and all c compiler is also generated same message but question is why WHYWHY said program run successfully ????



EDIT:

better way is WHYWHY put your complete project file to zip and place here.
 
Last edited:

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 ????.

Not only your compiler, every C compiler will do so, unless i is a controller register defined in header file..
 

i know Venkadesh_M sorry to use my compiler !!! edited
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top