View previous topic :: View next topic |
Author |
Message |
jcsquire Guest
|
byte variable declaration gives compile error |
Posted: Sat Jul 21, 2007 11:03 am |
|
|
Hey all,
Sorry about this newbie post, but sometimes in the beginning we all have embarrassingly obvious questions. Mine is: why am I getting a compile error in this extremely simple first try program of mine?
int8 byteBCD;
The compiler warns me that a numeric expression must occur here. My code in full context is below...all is written by the wizard except for my simple variable declaration. Thanks from someone just getting started.
//==========================================
void main()
{
////////////// Chip setup //////////////
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_oscillator(OSC_1MHZ|OSC_TIMER1);
set_tris_a(0b00111100); // RA2-5 are BCD inputs, rest LED outputs
set_tris_b(0b00000000); // all are LED outputs
////////////// Local variables //////////////
int8 byteBCD;
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jul 21, 2007 11:08 am |
|
|
Put all your local variable declarations at the beginning of the function.
Put your code after the variable declarations. |
|
|
Guest
|
|
Posted: Sat Jul 21, 2007 12:02 pm |
|
|
Thanks for getting me started, PCM Programmer, with your fast response! |
|
|
|