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