View previous topic :: View next topic |
Author |
Message |
pattousai
Joined: 23 Aug 2006 Posts: 37
|
It is only allowed global variables? |
Posted: Sun Apr 20, 2008 9:04 am |
|
|
Hi everyone, i have the 4.057 compiler and i'm using his IDE.
So... everytime i put a local variable (inside the main()) i get the error:
Code: |
A numeric expression must appear here
|
To fix that i have to put the variable at global scope. It is true that i can't have any local variables?
once i used the version 3.xxx and there i remember of using local variables.
thanks for the attention and sorry for the bad english |
|
|
pattousai
Joined: 23 Aug 2006 Posts: 37
|
|
Posted: Sun Apr 20, 2008 9:25 am |
|
|
hi everyone...
another thing that is going wrong is that i'm trying to print a int16 (as decimal unsigned int, i.e. using %d) over the serial and i'm getting the error:
Code: |
Print format type is invalid ::
|
The error dissapear when i put the hexadecimal format (%X)...
so... i can't display a int16 as decima?? |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Sun Apr 20, 2008 9:42 am |
|
|
There is no way anyone can help you without seeing your code.
Please post the section of code where you are having problems and the variable declarations. |
|
|
Ttelmah Guest
|
|
Posted: Sun Apr 20, 2008 9:49 am |
|
|
To print an int16, the format specifier is %ld. It always was. The new compiler though _warns_ you that the format is wrong. Some older ones didn't.
Local variables behave just as they have always done. Any variable declared inside a function is local. You need to post an example, so we can see what is wrong.
Best Wishes |
|
|
KU5D
Joined: 10 Feb 2008 Posts: 46 Location: Asheville, North Carolina
|
|
Posted: Sun Apr 20, 2008 1:23 pm |
|
|
For the 'numeric value' error, look for a mismatch in braces ( for every { you need a } ), misplaced semicolons, other typos above where the error occurs.
It's hard to answer the question without seeing the code... _________________ Confidence is the feeling you have right before you fully understand the situation... |
|
|
future
Joined: 14 May 2004 Posts: 330
|
|
Posted: Sun Apr 20, 2008 7:46 pm |
|
|
You must put all declarations at the beginning of the function before everything else. |
|
|
pattousai
Joined: 23 Aug 2006 Posts: 37
|
|
Posted: Tue Apr 22, 2008 8:59 pm |
|
|
thanks everybody for the help...
the display error was only the lack of the L...
and about the variables... well, i noted that the compiler not permitted if the definition is inside the while(true) (i guess that makes sense), is just put inside of a condition test (if) that it is allowed
again, thanks very much |
|
|
|