<div dir="ltr">Excellent - I'll submit a PR for the include in the first snippet. <br><br>I've become more au fait with the different idioms today, and this description is very helpful. <br><br>Best, Mike<br><br>On Tue, Apr 5, 2022 at 8:47 PM Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> wrote:<br>><br>><br>> Le 05/04/2022 à 01:28, Michael Sumner a écrit :<br>> > Hello, the warp tutorial  needs at least inclusion of "cpl_conv.h" for<br>> > CPLMalloc to work.<br>> ><br>> > <a href="https://gdal.org/tutorials/warp_tut.html">https://gdal.org/tutorials/warp_tut.html</a><br>> ><br>> > But, I'd like to ask why it uses the style of the C examples (as per<br>> > the Raster API tutorial<br>> > <a href="https://gdal.org/tutorials/raster_api_tut.html">https://gdal.org/tutorials/raster_api_tut.html</a>) rather than the C++ -<br>> > i.e. it uses 'GDALDatasetH hSrcDS' declarations rather than<br>> > 'GDALDataset *poDataset', and all the 'GDAL<Functions>' rather than<br>> > '->' pointer syntax.<br>> ><br>> > Is that recommended, or is it just old style in this tutorial (because<br>> > the apps were originally C)?<br>><br>> Probably just the preference of the author of the example. At least the<br>> first code snippet<br>> (<a href="https://gdal.org/tutorials/warp_tut.html#a-simple-reprojection-case">https://gdal.org/tutorials/warp_tut.html#a-simple-reprojection-case</a>)<br>> uses some C++ with the GDALWarpOperation class so it could be<br>> potentially converted to full C++ (but you'll need to keep CPLMalloc()<br>> and not use new[] because GDALDestroyWarpOptions() expects panSrcBands<br>> and panDstBands to have been allocated with CPLMalloc())<br>><br>> Actually I see the second snippet<br>> (<a href="https://gdal.org/tutorials/warp_tut.html#creating-the-output-file">https://gdal.org/tutorials/warp_tut.html#creating-the-output-file</a>) does<br>> use some bits of C++ with the OGRSpatialReference class. It could be<br>> either fully converted to C++ (but some functions like<br>> GDALCreateGenImgProjTransformer() or GDALSuggestedWarpOutput() only<br>> exist in the C API, so you'd have to cast C++ dataset objects to C<br>> handles at some point. This also applies to the first snippet, which<br>> explains that using C functions is more practical to avoid those casts))<br>> or C.<br>><br>><br>> --<br>> <a href="http://www.spatialys.com">http://www.spatialys.com</a><br>> My software is free, but my time generally not.<br>><br><br><br>--<br>Michael Sumner<br>Software and Database Engineer<br>Australian Antarctic Division<br>Hobart, Australia<br>e-mail: <a href="mailto:mdsumner@gmail.com">mdsumner@gmail.com</a><br></div>