[mapserver-dev] Modernizing code base: C99 and maybe C++ ?

Steve Lime sdlime at gmail.com
Wed Nov 27 09:26:10 PST 2019


I don't think anyone has ranted about moving the code-base to C++ before -
although Rodrigo Cabral (the original Oracle Spatial driver author) was hot
on the idea years ago. Modernization is a good thing and you're probably
right regarding the continuation of the project - so I'm very supportive of
the idea.

Still, it's likely a lot of work depending on how far it was taken. I mean
does this mean turning xxxxxObj structures into proper C++ classes, etc...?
How would you see pulling off a conversion like that off? I mean, is this
something that would best be handled by a single developer (not pointing
fingers) under contract? If yes, how big a contact?

Definitely RFC worthy...

--Steve

On Tue, Nov 26, 2019 at 5:43 PM Even Rouault <even.rouault at spatialys.com>
wrote:

> Hi,
>
> the kind of topics that is always controversial, but I do think this is a
> matter of survival for the project. I can write C89 code for sure, but
> which
> bad thing did I do to still be obliged to do it :-) ? Should new
> contributors
> be constrained by that... 2020 is just in a few days :-)
>
> Do we have a strong reason to stay with C89 for our .c files ? Not being
> able
> to use for loop initial declarations ( that is "for( int i = 0; i < ... ;
> ++)"
> ) is the example of something really annoying. Or being able to put
> declarations in the middle of a function instead of putting them at the
> beginning of it. This makes code harder to read, maintain and more error
> prone
> because of potential accidental reuse of variables that shouldn't.
>
> All gcc and clang compilers from the last 10 years support C99. Regarding
> MSVC, MSVC >= 2015 has decent enough support of it. Do we need to support
> older MSVC versions ? I don't think so. Neither current GDAL nor PROJ can
> built with older versions
>
> For the record, PROJ requires C99 for its few remaining .c files (and
> C++11
> for .cpp. So does GDAL)
>
> Next topic would be a
>
> for i in *.c; do mv $i "`basename $i .c`.cpp"; done
>
> Well, maybe not like that, because I'm expecting a ton of warnings. But
> more
> on a case by case basis where someone needs to do non-trivial changes in
> part
> of the code.
>
> Being constrained by C deeply sucks honesty. Apart from the Linux kernel
> which
> still resists for good reasons, I can't think of a single one for
> MapServer.
>
> The main point where C sucks is string manipulation, and MapServer does a
> ton
> of it. Being able to use std::string would be such a relief.
>
> Ah for the record, we do have C++ in the code base: mapogr.cpp and the agg
> renderer.
>
> Even
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com
> _______________________________________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20191127/83a95798/attachment.html>


More information about the mapserver-dev mailing list