[Proj] Code style in Proj
Kurt Schwehr
schwehr at gmail.com
Mon Apr 30 12:45:23 PDT 2018
Thanks for the proj_coord(). I meant to look that up, but got interrupted
by a poopy diaper.
I would be happy to create a draft document for people to comment on. It
will be slow going as I only get little bits of time here and there for the
next week.
I do have to say that I don't like removing the math.h from the main file.
The cost is small and it frees you to refactor other headers without wide
ranging changes each time.
On Mon, Apr 30, 2018 at 6:00 AM, Kristian Evers <kreve at sdfe.dk> wrote:
> Kurt,
>
> I think it looks good. I tried compiling the code and again I had the
> problem with declarations like
>
> XY xy = {0.0, 0.0};
>
> I’ve fixed those in a fork of your gist. See revision 2 in [0] for a
> proposed solution that I think
> is in line with your ideas
>
> I like how you’ve separated includes from the standard library on the PROJ
> internal includes. On
> a related note (for those who don’t already know) I have recently
> introduced the proj_math.h
> header which is intended as a PROJ replacement of math.h. proj_math.h’s
> purpose in life is to
> make sure that we can use C99 math functions on systems where they are not
> available.
> proj_math.h includes math.h and defines functions such as isnan() and
> hypot(). This way they
> can be used as you would on a C99-compatible system as long as proj_math.h
> is included.
> See revision 3 in [0].
>
> Would you be willing to write up a simple style guide for PROJ based on
> the ideas you have presented in
> this thread?
>
> /Kristian
>
> [0] https://gist.github.com/kbevers/17ec703942646e401b28a0975b2877
> 1d/revisions
>
> On 24 Apr 2018, at 12:05, Mateusz Loskot <mateusz at loskot.net> wrote:
>
> On 24 April 2018 at 11:45, Thomas Knudsen <knudsen.thomas at gmail.com>
> wrote:
>
> In C too, but since C99.
>
>
> AFAIK this only applies to the "for (int i = 0; i < n; i++)" syntax.
>
> while (...) {
> int i = 123, j = 345;
> k = i + j;
> }
>
> has been correct (and imho, preferable) syntax since K&R C
>
>
> AFAIK, it's about compound statement.
> C89 requires declaration at the top of blocks, while C99 lifts that:
>
> $ cat test.c
> int main()
> {
> int i = 0;
> while (i < 10)
> {
> int j = 345;
> i = i + j;
> }
>
> {
> int z = 0;
> z = 1;
> }
> int x = 1;
> }
>
> $ gcc -std=c89 -pedantic test.c
> test.c: In function ‘main’:
> test.c:14:5: warning: ISO C90 forbids mixed declarations and code
> [-Wdeclaration-after-statement]
> int x = 1;
> ^~~
>
> $ gcc -std=c99 -pedantic test.c
> $
>
>
> Best regards,
> --
> Mateusz Loskot, http://mateusz.loskot.net
> _______________________________________________
> Proj mailing list
> Proj at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/proj
>
>
>
> _______________________________________________
> Proj mailing list
> Proj at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/proj
>
--
--
http://schwehr.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20180430/5c009dcf/attachment.html>
More information about the Proj
mailing list