CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Int declaration inside function? Possible ?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
lejm
Guest







Int declaration inside function? Possible ?
PostPosted: Tue Jan 19, 2010 5:02 pm     Reply with quote

I need to make Int variable inside function:

Like this :
Code:

void SOMETHING(void){
int z=3;
....
}

However if I try to do that I'm getting an error " Expression must evaluate to a constant".

If I make Int outside of function I can access it from the function.
But to make the code nice-looking I want to make no global variables.
lejm
Guest







PostPosted: Tue Jan 19, 2010 5:04 pm     Reply with quote

One more thing : Is there a short simple method to split Int16 into two Int8 ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 19, 2010 5:19 pm     Reply with quote

Post a test program that shows the problem. For example, the test
program shown below compiles with no errors with vs. 4.104.
Code:

#include <16F877.H>
#fuses XT, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

void SOMETHING(void)
{
int z=3;

}

//======================================
void main()
{



while(1);
}


Quote:
Is there a short simple method to split Int16 into two Int8 ?

The manual has a summary page of all CCS functions. It's on page 151
in the Acrobat Reader.
Quote:
BUILT-IN-FUNCTIONS

It lists functions by type of use.

If you look at the list of functions in this section, you will quickly find
what you want. (For future reference).
Quote:
BIT/BYTE MANIPULATION

To answer your question, look at the make8() function in the manual.
lejm
Guest







PostPosted: Tue Jan 19, 2010 5:32 pm     Reply with quote

i'v got 4.074 compiler version.

thx4 fast answer
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group