View previous topic :: View next topic |
Author |
Message |
lejm Guest
|
Int declaration inside function? Possible ? |
Posted: Tue Jan 19, 2010 5:02 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
lejm Guest
|
|
Posted: Tue Jan 19, 2010 5:04 pm |
|
|
One more thing : Is there a short simple method to split Int16 into two Int8 ? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jan 19, 2010 5:19 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
lejm Guest
|
|
Posted: Tue Jan 19, 2010 5:32 pm |
|
|
i'v got 4.074 compiler version.
thx4 fast answer |
|
![](templates/subSilver/images/spacer.gif) |
|