[Proj] Use of C++

Heiko Klein Heiko.Klein at met.no
Thu May 24 08:39:35 EST 2018


Hei,

C++ as internal language is no problem for me. But when it turns to API,
C-objects and C++ objects usually don't work together, even things as
simple as strings are incompatible, so integration with other languages
(python,R,java and others) only works by using a C++->C wrapper. These
wrappers exist, but create an additional burden. If possible, I wouldn't
like to see any C++ code exposed.

Heiko

On 2018-05-23 20:30, Mateusz Loskot wrote:
> On 23 May 2018 at 19:59, Andrew Bell <andrew.bell.ia at gmail.com> wrote:
>> That said, the issue I have with the GDAL API, which is mentioned as a
>> model, is that it's complicated in that it's always unclear who owns what
>> and what needs to be freed by the application, etc.  It creates bugs and
>> ambiguities.  Whether the API is C or C++, allowing the library to manage
>> data to the extent possible is desirable.  Looking at the proj 4 API, there
>> are only a few instances where you might need to look at the source code or
>> documentation on this (proj_list..., a few calls that take non-const char *
>> and a few that take char **), so not a bad starting point.
> 
> Since the discussion touches the aspect if/how choice of C++ affects API
> discoverability and transparency [1], I'd only point out that costness of
> pointer/pointee does not necessarily indicate ownership responsibility.
> 
> All three are perfectly delete/free-able:
> 
> char const* f1() { return new char{'\a'}; }
> char* const f2() { return new char{'\a'}; }
> char const* const f3() { return new char{'\a'}; }
> 
> Although I'm mostly C++11+ user, I agree with Andrew clean OOP interface
> can be achieved using both, C or C++.
> (GTK always served me as an excellent example of clean OOP in C.)
> 
> Finally, if Even's choice is C++, I'm fairly certain Even will not go
> for equivalent
> of GDAL's CPL strings, lists, etc. jugglers, but stick to C++ standard library.
> 
> [1] https://accu.org/index.php/journals/1572
> 
> Best regards,
> 

-- 
Dr. Heiko Klein                   Norwegian Meteorological Institute
Tel. + 47 22 96 32 58             P.O. Box 43 Blindern
http://www.met.no                 0313 Oslo NORWAY


More information about the Proj mailing list