<div dir="ltr"><div><div>Yes, I understand the intention, and have used the same kind of constructs myself earlier. I stopped using it roughly 20 years ago, since my interpretation of the standard text led me to conclude that the construct was not complying.<br><br></div>Since your tests indicate that my interpretation was wrong, I have googled around a bit to see what other people think, and it actually appears that I was wrong. The alternative exegesis of the gospel is given by a number of commentators on [0], so I suppose I was wrong - and will unfortunately now have to reread the standard to be sure :-)<br><br></div>/Thomas<br><br>[0] <a href="https://stackoverflow.com/questions/7859424/why-was-mixing-declarations-and-code-forbidden-up-until-c99">https://stackoverflow.com/questions/7859424/why-was-mixing-declarations-and-code-forbidden-up-until-c99</a><br><br> </div><div class="gmail_extra"><br><div class="gmail_quote">2018-04-30 15:57 GMT+02:00 Kristian Evers <span dir="ltr">&lt;<a href="mailto:kreve@sdfe.dk" target="_blank">kreve@sdfe.dk</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div style="word-wrap:break-word;line-break:after-white-space">
Thomas,
<div><br>
</div>
<div>Actually this was part of Kurts original proposal. The else is not missing here as you can see from the original code [0].</div>
<div>The code passed my compiler just fine with all the C89 specific flags turned on (as mentioned in an earlier email in</div>
<div>this thread). So here it is just a block introduced to create a scope where declarations can be made more local to</div>
<div>where they are used. If that is prohibited according to the standard I don’t know. I don’t have other ways to test</div>
<div>standard compliance than to compile the code with C89 flags turned on. For a more thorough test we can create a</div>
<div>pull request with the proposed changes and see how the various compilers on Travis and AppVeyor fares.</div>
<div><br>
</div>
<div>/Kristian</div>
<div><br>
</div>
<div>[0] <a href="https://github.com/OSGeo/proj.4/blob/d0fefa4104d9b655d59e400cda616f0b4d407071/src/PJ_aeqd.c#L110-L126" target="_blank">
https://github.com/OSGeo/proj.<wbr>4/blob/<wbr>d0fefa4104d9b655d59e400cda616f<wbr>0b4d407071/src/PJ_aeqd.c#L110-<wbr>L126</a></div><div><div class="h5">
<div><br>
<div><br>
<blockquote type="cite">
<div>On 30 Apr 2018, at 15:44, Thomas Knudsen &lt;<a href="mailto:knudsen.thomas@gmail.com" target="_blank">knudsen.thomas@gmail.com</a>&gt; wrote:</div>
<br class="m_-1263289084356569332Apple-interchange-newline">
<div>
<div dir="ltr">I think line 116 in Kristian&#39;s revised version misses an &quot;else&quot;: Gnu C, and probably many other compilers, accepts &quot;naked&quot; compound statements, but I do not think it is in accordance with the C89 standard<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2018-04-30 15:00 GMT+02:00 Kristian Evers <span dir="ltr">
&lt;<a href="mailto:kreve@sdfe.dk" target="_blank">kreve@sdfe.dk</a>&gt;</span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;line-break:after-white-space">Kurt,
<div><br>
</div>
<div>I think it looks good. I tried compiling the code and again I had the problem with declarations like</div>
<div><br>
</div>
<div><span class="m_-1263289084356569332m_-1500459827085182831Apple-tab-span" style="white-space:pre-wrap"></span>XY xy = {0.0, 0.0};</div>
<div><br>
</div>
<div>I’ve fixed those in a fork of your gist. See revision 2 in [0] for a proposed solution that I think</div>
<div>is in line with your ideas</div>
<div><br>
</div>
<div>I like how you’ve separated includes from the standard library on the PROJ internal includes. On</div>
<div>a related note (for those who don’t already know) I have recently introduced the proj_math.h</div>
<div>header which is intended as a PROJ replacement of math.h. proj_math.h’s purpose in life is to</div>
<div>make sure that we can use C99 math functions on systems where they are not available.</div>
<div>proj_math.h includes math.h and defines functions such as isnan() and hypot(). This way they</div>
<div>can be used as you would on a C99-compatible system as long as proj_math.h is included.</div>
<div>See revision 3 in [0].</div>
<div><br>
</div>
<div>Would you be willing to write up a simple style guide for PROJ based on the ideas you have presented in</div>
<div>this thread?</div>
<div>
<div><br>
</div>
<div>/Kristian</div>
<div><br>
</div>
<div>[0] <a href="https://gist.github.com/kbevers/17ec703942646e401b28a0975b28771d/revisions" target="_blank">https://gist.github.com/kb<wbr>evers/17ec703942646e401b28a097<wbr>5b28771d/revisions</a></div>
<div>
<div class="m_-1263289084356569332h5">
<div><br>
<blockquote type="cite">
<div>On 24 Apr 2018, at 12:05, Mateusz Loskot &lt;<a href="mailto:mateusz@loskot.net" target="_blank">mateusz@loskot.net</a>&gt; wrote:</div>
<br class="m_-1263289084356569332m_-1500459827085182831Apple-interchange-newline">
<div>
<div>On 24 April 2018 at 11:45, Thomas Knudsen &lt;<a href="mailto:knudsen.thomas@gmail.com" target="_blank">knudsen.thomas@gmail.com</a>&gt; wrote:<br>
<blockquote type="cite">
<blockquote type="cite">In C too, but since C99.<br>
</blockquote>
<br>
AFAIK this only applies to the &quot;for (int i = 0;  i &lt; n; i++)&quot; syntax.<br>
<br>
while (...) {<br>
   int i = 123, j = 345;<br>
   k = i + j;<br>
}<br>
<br>
has been correct (and imho, preferable) syntax since K&amp;R C<br>
</blockquote>
<br>
AFAIK, it&#39;s about compound statement.<br>
C89 requires declaration at the top of blocks, while C99 lifts that:<br>
<br>
$ cat test.c<br>
int main()<br>
{<br>
   int i = 0;<br>
   while (i &lt; 10)<br>
   {<br>
       int j = 345;<br>
       i = i + j;<br>
   }<br>
<br>
   {<br>
       int z = 0;<br>
       z = 1;<br>
   }<br>
   int x = 1;<br>
}<br>
<br>
$ gcc -std=c89 -pedantic test.c<br>
test.c: In function ‘main’:<br>
test.c:14:5: warning: ISO C90 forbids mixed declarations and code<br>
[-Wdeclaration-after-statement<wbr>]<br>
    int x = 1;<br>
    ^~~<br>
<br>
$ gcc -std=c99 -pedantic test.c<br>
$<br>
<br>
<br>
Best regards,<br>
-- <br>
Mateusz Loskot, <a href="http://mateusz.loskot.net/" target="_blank">http://mateusz.loskot.net</a><br>
______________________________<wbr>_________________<br>
Proj mailing list<br>
<a href="mailto:Proj@lists.maptools.org" target="_blank">Proj@lists.maptools.org</a><br>
<a href="http://lists.maptools.org/mailman/listinfo/proj" target="_blank">http://lists.maptools.org/mail<wbr>man/listinfo/proj</a></div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
<br>
______________________________<wbr>_________________<br>
Proj mailing list<br>
<a href="mailto:Proj@lists.maptools.org" target="_blank">Proj@lists.maptools.org</a><br>
<a href="http://lists.maptools.org/mailman/listinfo/proj" rel="noreferrer" target="_blank">http://lists.maptools.org/mail<wbr>man/listinfo/proj</a><br>
</blockquote>
</div>
<br>
</div>
______________________________<wbr>_________________<br>
Proj mailing list<br>
<a href="mailto:Proj@lists.maptools.org" target="_blank">Proj@lists.maptools.org</a><br>
<a href="http://lists.maptools.org/mailman/listinfo/proj" target="_blank">http://lists.maptools.org/<wbr>mailman/listinfo/proj</a></div>
</blockquote>
</div>
<br>
</div>
</div></div></div>

<br>______________________________<wbr>_________________<br>
Proj mailing list<br>
<a href="mailto:Proj@lists.maptools.org">Proj@lists.maptools.org</a><br>
<a href="http://lists.maptools.org/mailman/listinfo/proj" rel="noreferrer" target="_blank">http://lists.maptools.org/<wbr>mailman/listinfo/proj</a><br></blockquote></div><br></div>