Search code examples
c++visual-studioheader-filesgdal

GDAL Library Header Files Error and Warningsin With Visual Studio 2019


I am using GDAL in visual studio 2019 community version,and I used the sample code in the their official site which is down below,the program compiles, runs and outputs fine, but I got a list of errors and warnings, I don't know if I should ignore them or make some change on header files, anyone encounter issues like this before? hope someone could give me some advice, thank you. sample code:

/*gdal_test*/
#include <iostream>  
#include <gdal_priv.h>
#include <cpl_conv.h> 

using namespace std;

int main()
{
    const char* pszFile;
    GDALAllRegister();
    pszFile = "E:/190807/mosaic_data/S2_1_170215.tif";
    GDALDataset* poDataset = (GDALDataset*)GDALOpen(pszFile, GA_ReadOnly);
    GDALRasterBand* poBand = poDataset->GetRasterBand(1);
    int xsize = poBand->GetXSize();
    int ysize = poBand->GetYSize();
    cout << xsize << endl;
    cout << ysize << endl;

    system("pause");
    return 0;
}

error list mainly contains these three main issue:

Error (active)  E0065   expected a ';'  gdaltest    C:\MSVC_Library\GDAL\warmerda\bld\include   C:\MSVC_Library\GDAL\warmerda\bld\include\ogr_geometry.h    387     

Error (active)  E1455   member function declared with 'override' does not override a base class member  gdaltest    C:\MSVC_Library\GDAL\warmerda\bld\include   C:\MSVC_Library\GDAL\warmerda\bld\include\ogr_geometry.h    1139        

Warning C26812  The enum type 'CPLErr' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).   gdaltest    C:\MSVC_Library\GDAL\warmerda\bld\include   C:\MSVC_Library\GDAL\warmerda\bld\include\cpl_error.h   244     

should I change the syntax in header files? will change it effect something? Or should I just ignore these errors?


Solution

  • You state that your program, "compiles, runs and outputs fine," so, the errors you are seeing are being reported by the "Intellisense" tool in Visual Studio.

    To stop displaying these, go to the "Error List" window and select the "Build Only" option:

    enter image description here

    The C26812 warning message can be disabled as described in my answer to your recent question.