Quote:
|
Originally Posted by sear_yoda
I'm trying not to be a total idiot here by checking all over the forums first, and reading all of the documentation, but I CANNOT figure out how to initilize a simple integer variable 'pressure' that equals the value from the pressure reader on analog input 1.
static unsigned int pressure = Get_Analog_Value(rc_ana_in01);
No matter where I put that, I can't get it to compile. It will compile fine in a few certain places in user_routines.c if it's just pressure = 0, but not this line. EVen if I split it up, it still doesn't work. All I get is syntax errors.
Does anyone else wish this compiler was a tiny bit more descriptive in its error debugging? I've been learning Java this year using the NetBeans IDE, and this MPLAB IDE makes me want to hurl my laptop across the room.
All of my coding depends on being able to initialize variables (well, duh) so this is really a stopping point for me. My entire team is getting sort of pissed off, becuase I just sit there looking angry every meeting trying to get the code to work.
Thanks in advance for any replies I recieve...I must be doing some simple thing wrong.
-Chris
|
What I supect your problem might be is that C, unlike Java or C++ is requires that all variable initializations be done at the very top of the function. You cannot have any code except for other variable initializtion before it. So, I would suggest sticking
static unsigned int pressure;
at the top of the function and then
pressure = Get_Analog_Value(rc_ana_in01);
where ever it is more appropiate.
If this isn't the problem, could you post the message and some code snippets?