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

It is only allowed global variables?

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



Joined: 23 Aug 2006
Posts: 37

View user's profile Send private message

It is only allowed global variables?
PostPosted: Sun Apr 20, 2008 9:04 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Apr 20, 2008 9:25 am     Reply with quote

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: 1924
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Apr 20, 2008 9:42 am     Reply with quote

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







PostPosted: Sun Apr 20, 2008 9:49 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Apr 20, 2008 1:23 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Apr 20, 2008 7:46 pm     Reply with quote

You must put all declarations at the beginning of the function before everything else.
pattousai



Joined: 23 Aug 2006
Posts: 37

View user's profile Send private message

PostPosted: Tue Apr 22, 2008 8:59 pm     Reply with quote

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
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