Jump to content
chief

Problem With If, Else If Chain

Recommended Posts

Can anybody tell me why the compiler doesn't like this bit of code?

 

void startup()
{
  while(1)//startup loop - chk subd conn, last_state, pause, check S1
  {
		   if(no_conn) //test if PS subd is connected
		{
			lcd_gotoxy( 0, 0 );
		lprintf("PS not connected");
		}
			else if (last_state == S)//SC
				{recover_SC();}
			else if (last_state == L)//NL
				{recover_NL();}
			else if (last_state == X)//exit
				{recover_exit();}
			else {
				lcd_gotoxy( 0, 0 );
				lprintf("PS connected");
				lprintf("\nS1 to start");
				}
			delay_ms(100);
			if(S1 == 0)
				{				 
				while( S1 == 1) 
				do_next_thing();
				}
	}//end while loop
}//end startup

 

I get the message:

 

Building...

"C:\Program Files\SourceBoost\boostc++_pic16.exe" bias_burn_nr.cpp -t PIC16F877A -idx 1 -obj Debug -d _DEBUG

bias_burn_nr.cpp(75:25): error: unknown identifier 'L'

bias_burn_nr.cpp(75:25): error: invalid operand 'L'

bias_burn_nr.cpp(75:22): error: failed to generate expression

bias_burn_nr.cpp(75:6): error: error in the 'else' body of 'if' expression

BoostC++ Optimizing C++ Compiler Version 7.02 (for PIC16 architecture)

http://www.sourceboost.com

Copyright© 2004-2011 Pavel Baranov

Copyright© 2004-2011 David Hobday

 

Licensed to (NAME) under Single user Pro License for 1 node(s)

Limitations: PIC12,PIC16 max code size:Unlimited, max RAM banks:Unlimited

 

 

bias_burn_nr.cpp

 

failure

error: failed

Done

Share this post


Link to post
Share on other sites

How have you declared S, L and X ?

 

Are they constants, enums or variables ?

 

Does L really exist ?

 

Try to avoid single letter names as they can get confused with register and bit names already defined in the PIC header file.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites
How have you declared S, L and X ?

 

Are they constants, enums or variables ?

 

Does L really exist ?

 

Try to avoid single letter names as they can get confused with register and bit names already defined in the PIC header file.

 

Cheers

 

Reynard

 

Thank you Reynard,

It was a typo in my declarations. That's what I get for writing code on a netbook! Thanks for your help.

I'm also changing them from letters to words.

Brian

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×