Em 25/2/2010 14:09, Jason Hsu escreveu: > The code is as follows: > > void delay_1_msec (void) > { > count =3D 110; > while (count>0) > { > count--; > } > } > > Everything compiles and works when I use this function declaration in Pro= gram A. > > I have a second program, Program B that also works as expected. > > However, when I cut and paste this code snippet from Program A to > Program B (which also worked), Program B refuses to compile (even with > the line calling the function commented out). The errors I'm getting > are: > no identifier in declaration > > missing basic type; int assumed > > ";" expected > > Given that this same code worked in another program, I doubt that this > is a syntax error. Yes, I have declared the variable count as an > unsigned char. In fact, I have a similar pre-existing function in > Program B that caused no problems. The function declaration is: > > void delay_20_usec(void) > { > count =3D 2; > while (count>0) > { > count--; > } > } > > What am I overlooking? > = As others pointed out, it may be that you forgot to declare 'count' in the other program, or perhaps you defined a macro that has the same name as some symbol in your function. It is not good practice to rely in globally declared variables, specially in this case, where the variable is obviously never needed outside the function. Declare the 'count' variable inside you function instead. Why don't you instead of: void delay_20_usec(void) { count =3D 2; while (count>0) { count--; } } Just use: void delay_20_usec(void) { char count; for( count =3D 2; count !=3D 0; count-- ); } The 'for' construct is much more concise, elegant and easier to understand. Best regards, Isaac __________________________________________________ Fa=E7a liga=E7=F5es para outros computadores com o novo Yahoo! Messenger = http://br.beta.messenger.yahoo.com/ = -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist