[gdal-dev] Minimum supported C and C++ standards

Kurt Schwehr schwehr at gmail.com
Mon May 9 10:28:48 PDT 2016


Here is my current take on language standards

- I am working on a C++11/14 C99/11 proposal.  I despirately want to be
able to use C++11 to make GDAL more robust
- As it stands I will vote >>>against<<< my proposal any time soon - until
with have a bunch of proposals for changes to GDAL that require new
language versions or someone rewrites my proposal to be much more compelling
- We have lots of work that we can do to make GDAL maintenance / debugging
easier that does not require newer language versions
- We have successfully ( at least in my opinion ) stuck a toe in the C++11
world with CPL_FINAL, CPL_DISALLOW_COPY_ASSIGN, NULL_AS_NULLPTR, and
my std::lock_guard<std::mutex> experiments.  We can probably do a bit more
if we are careful.
- I think having an experimental autotest2 C++11/14 only testing tree might
be the way to start.  Those who want to can try it out or look through what
is possible and it won't impact the main tree or the existing C++ tests.


I would be happy to start contributing to
https://trac.osgeo.org/gdal/browser/trunk/autotest2, especially if we call
it experimental and I can get help with adding a build system.  I have
>5000 lines of C++ in 32 test files that mostly cover the port directory
right now.  I got hung up on trying to create a working initial version in
a separate github tree.  Adding it to the existing svn tree would get me
around that issue (it's an internal work thing).  Here is
cpl_string_test.cc... it's super boring.

   https://gist.github.com/schwehr/02128959ee78d56b553defa0a527bdf2

It's written using the Google C++ style guide and is based on gunit, gmock
and glog.

- https://google.github.io/styleguide/cppguide.html
- https://github.com/google/googletest
- https://github.com/google/glog



On Mon, May 9, 2016 at 2:33 AM, Mateusz Loskot <mateusz at loskot.net> wrote:

> On 7 May 2016 at 19:10, Kurt Schwehr <schwehr at gmail.com> wrote:
> >>
> >> If we move to a later C++ standard, or even use features of C++98 we
> >> currently
> >> don't use, I'd advocate for using things that are obviously making the
> >> code
> >> better / more readable. Honestly who finds that
> >> "std::unique_ptr<int *, std::function<void(char *)>> Vals(CPLCalloc(256,
> >> 0),
> >> CPLFree);" is obviously more readable, efficient and less error prone
> than
> >> "std::vector Vals(256,0)" ?
> >>
> >
> > This is cart before the horse but... as fast as I can so expect typos.
> Now
> > just think of a ~1K long function or method with tons of instances and
> lots
> > of places to bailout successfully or as failures.  We have > 9K
> > free/CPLFree/CPLdelete/CPLDestroys that could be < ~100.
> > [...]
>
> ...the very long story short, your desire is to introduce the RAII idiom
> across GDAL codebase. Awesome!
> I'm sure 99% of GDAL committers will welcome this idea.
> Then, **next** question is how we want to implement it:
> using C++11+ features, home-brewed smart pointer class(es), etc.
>
> Upgrading to C++11+ just for the sake of upgrade, makes little sense to me.
> Especially if folks are not certain about it, don't use those features
> daily,
> don't feel comfortable...it may cause more harm.
>
> Best regards,
> --
> Mateusz Loskot, http://mateusz.loskot.net
>



-- 
--
http://schwehr.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160509/d2d5eee1/attachment-0001.html>


More information about the gdal-dev mailing list