GDAL Library Header Files Error and Warningsin With Visual Studio 2019

别来无恙 提交于 2021-01-28 11:01:30

问题


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?


回答1:


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:

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



来源:https://stackoverflow.com/questions/59676077/gdal-library-header-files-error-and-warningsin-with-visual-studio-2019

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!