<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>Il giorno 15/lug/2011, alle ore 14.24, Peter Geoghegan ha scritto:</div><br><blockquote type="cite"><div><br>While I thank you for your efforts, I don't see why we have to<br>explicitly use C89 to avoid the warning, since we're only avoiding the<br>warning under circumstances exactly consistent with the use of the<br>idiom.<br><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" color="#144FAE"><br></font></font></div></blockquote><blockquote type="cite"><div>What's valid in C89 is valid in C99, with very few exceptions. Just<br>because this is arguably bad style in C99 does not mean that we should<br>see a warning - warnings are supposed to prevent downright errors that<br>are still valid code. No one would seriously suggest that we should<br>have warnings when C style casts are used in C++ on non-POD types,<br>even though they're extremely hazardous there. Precedent matters.<br><br></div></blockquote><div><br></div><div>Hm, I just tried to implement what seemed to be the general accepted solution</div><div>to your problem.</div><div>That said, if I understand your point, you want to develop a huge crossplatform</div><div>codebase written in C, but:</div><div>- You can't fully use C99 because some compilers won't support it (MSVC).</div><div>- So your code is C89, but you can force C89 compliance because you rely</div><div>  on some widely supported C99 feature (I suppose these are trivial things like</div><div>  mixing declarations and code or //-style comments, or the scope of the</div><div>  for() initializers, what else?)</div><div>- You want to support a lot of platforms and compilers, but you're reluctant </div><div>  to tune your build system for specific compilers</div><div>- You don't want to deal with compilers differences with macro tricks because</div><div>  of "code hygiene"</div><div>- You want your code to compile warning-clean on all the compilers you support,</div><div>  but without disabling warnings from the command line.</div><div><br></div><div>Clang or not, I don't think these requirements are generally easy to fulfill,</div><div>you need to make a choice.</div><div><br></div><div>Anyway, this patch suppress the warning also in -std=gnu89 mode, which </div><div>is the default for gcc, so you could simply pass -std=gnu89 to both compilers</div><div>and you'll have true drop-in compatibility.</div><div><br></div><div><br></div><div><br></div><blockquote type="cite"><div>-- <br>Peter Geoghegan       <a href="http://www.2ndQuadrant.com/">http://www.2ndQuadrant.com/</a><br>PostgreSQL Development, 24x7 Support, Training and Services<br></div></blockquote></div><div><br></div>Bye,<br><div>Nicola</div><div><br></div><div><br></div><div>P.S. this was just an exercise to me, so reviews for the patch are welcomed anyway</div><div>P.P.S. clang accepts flexibles arrays also with -std=c89 -pedantic. Is it compliant?</div></body></html>