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.

#if undefined identifier in keil

Status
Not open for further replies.

embpic

Advanced Member level 3
Joined
May 29, 2013
Messages
742
Helped
80
Reputation
160
Reaction score
77
Trophy points
1,308
Location
india
Activity points
5,213
hello frnds
i was doing and trying to compile code with micro #if but it gives me error of undefined identifier at #if.

my code is

sbit sw1=P0^0;

#if sw1==0
sbit led1=P1^0;
#else
sbit led1=P1^2;
#endif

thanx

- - - Updated - - -

even i try by #defined that var.

and also

#if sw1 alzo
 

Hello masters help me i am trying from last week
thanx
 

u may try this

#define sw1 p0^0;
#define led1 p1^0;

if(sw1==1)
{
led=0; // Assume on =0 off=1
}
else
{
led=1;
}
 

Yes thanx but i want to check sw condition in preprocessor so pin assigment can be changed. As i have shown.
 

i want to check sw condition in preprocessor
Think! How should this work? The state of pin sw can't be known at compile time, thus it's impossible to take preprocessor actions based on it. Conditional preprocessor commands can only work with constant expressions.
 

I want to make code as change as per sw1 position.
Means do different if sw1is closed and do different if open.
 

You really need to think.

The compiler runs on your PC. How can it read the switch and perform conditional compilation based on it's state?
 

K thanx but is there any way to assign pin no to different depend upon switch condition.
And which condion fan be checked with
#if

Once again thanx.
 

Never Make programming complex by changing basic. If Ur SW sensing is possible during running condition & u can make action according
 

Agree but where i can use
#if
 

which condion can be checked with #if
as said constant expressions, e.g. compiler version, defined hardware targets, software revision

is there any way to assign pin no to different depend upon switch condition
All regular processor instructions. In detail, you have to check which instructions can be used effectively for a particular processor.

If I/O-bits are acessed with bit set instructions, as for 8051 or PIC, it's probaly best to write alternative code blocks or even complete functions that are selected depending on the hardware switch.
 
  • Like
Reactions: embpic

    embpic

    Points: 2
    Helpful Answer Positive Rating
Got it . Means to make code portable to run on different hardware or compiler.
Do you have any examples to use me portability in my codes.
.
 

Hi,

You compile your code in your PC and run that hex file in your board, or large quantity product, how it is possible that your PC find out that what is status of that PIN in your large quantity Product and compile accordingly.
You really need to think.

Regards,
 

Yes i was in thinking in different way till posting this query. After having reply from frnds i got the true...
Thanx
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top