Perhaps your colleague uses this reversed order specifically BECAUSE it inherently prevents the single equals sign mistake. It converts it from a warning to an error. Sean On Mon, Mar 12, 2012 at 6:53 AM, Jim wrote: > Using this example:- > > if(iBlock_Size =3D 0) > { > =A0 =A0return 0; > } > gives this:- > Warning [758] C:\Source\UI_Test\dongle.c; 107. constant conditional branc= h: possible use of "=3D" instead of "=3D=3D" > > BUT still builds ok.. > > obviously the syntax should be > > if(iBlock_Size =3D=3D 0) > { > =A0 =A0return 0; > } > > but my colleague uses > if(0 =3D=3D iBlock_Size) > { > =A0 =A0return 0; > } > > Which although syntactically correct, just doesn't feel right. > He uses it for ALL ifs =A0so > if(127 < iBlock_Size) > { > =A0 =A0return 0; > } > > Which is counter intuitive in my mind. Perhaps I am just getting old? > > They should ALL produce an error with > if(0 =3D iBlock_Size) > { > =A0 =A0return 0; > } > as you cannot assign to the 0 on the left side > Error =A0 [202] C:\Source\UI_Test\dongle.c; 107.19 only lvalues may be as= signed to or modified > > > > > On Mon 12/03/12 10:18 AM , Tamas Rudnai tamas.rudnai@gmail.com sent: >> On 12 March 2012 09:20, Chris Roper caroper@gma >> il.com> wrote: >> > I agree with your colleague. >> > I use several compilers and several "C Type" >> languages, not all of them> will give a warning but all will generate th= e >> error.> >> >> You mean if you write: >> >> if ( 0 =3D x ) ... >> >> then not all C compiler will generate an error? >> >> Tamas >> >> >> >> >> > >> > On 12 March 2012 10:03, Jim jimf@we >> bstudios.co.uk> wrote:> >> > > I have a colleague who insists on using this >> reverse syntax> > >> > > if(0 =3D=3D x) { >> > > ...do stuff >> > > } >> > > >> > > which I find odd to read at the best of >> times...> > >> > > We're using embedded C, (Hitech), and >> whilst> > if(x =3D0) =A0 doesn't throw an error, it does throw >> a warning.> > >> > > oh well. >> > > >> > > -Jim >> > > >> > > >> > > > >> > > > >> > > > >> > > > Isn't that just what warnings are for? It >> compiles OK but it might not> be >> > > > what you wanted. Just like: >> > > > >> > > > if (A=3DB){ >> > > > ... >> > > > >> > > >> > > >> > > >> > > >> > > -- >> > > http://www.piclist.com PIC/SX FAQ & list >> archive> > View/change your membership options at >> > > http://mailman.mit.edu/mailman/listinfo/piclist> > >> > -- >> > http://www.piclist.com PIC/SX FAQ & list >> archive> View/change your membership options at >> > http://mailman.mit.edu/mailman/listinfo/piclist> >> >> >> >> -- >> int main() { char *a,*s,*q; printf(s=3D"int main() { char *a,*s,*q; >> printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", >> q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } >> -- >> http://www.piclist.com PIC/SX FAQ & list archiveView/change your members= hip options at >> http://mailman.mit.edu/mailman/listinfo/piclist >> >> > > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .