Hacker Newsnew | comments | show | ask | jobs | submit login

GCC is indeed not the only compiler around, which is why I said "at least" :-) Even if you're stuck with some other compiler for production builds, it's handy to be compiling regularly with a variety of compilers so as to benefit from the union of the diagnostic abilities of all of them.

The construct is a useful idiom, but oftentimes there would be or ought to be a local coding standard recommending that you make what you're doing explicit by comparing the assignment result to the appropriate flavour of zero:

  if ((foo = bar) != NULL)
Now everybody can see what's going on, the warning doesn't arise, and no pedants can complain about the theoretically-unnecesary parentheses in `if ((foo = bar))`.



> GCC is indeed not the only compiler around, which is why I said "at least" :-) Even if you're stuck with some other compiler for production builds, it's handy to be compiling regularly with a variety of compilers so as to benefit from the union of the diagnostic abilities of all of them.

In my case, at least one of the compilers in question was for the 8051, the platform that won't fucking die. Due to the peculiarities of the aforementioned piece of silicon crap, the compiler was not entirely ANSI-compliant (various #pragmas were actually required to produce working code, indicating various parameters related to memory organisation and the such), thus making it rather difficult to compile the codebase with anything but that particular compiler.

> The construct is a useful idiom, but oftentimes there would be or ought to be a local coding standard recommending that you make what you're doing explicit by comparing the assignment result to the appropriate flavour of zero

This is the solution I adhere to as well.

-----




Applications are open for YC Winter 2016

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: