Visual Studio 2019中的GDAL库头文件错误和警告 [英] GDAL Library Header Files Error and Warningsin With Visual Studio 2019

查看:111
本文介绍了Visual Studio 2019中的GDAL库头文件错误和警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2019社区版本中使用GDAL,并且在下面的官方网站中使用了示例代码,程序可以编译,运行和输出正常,但是我得到了错误和警告的列表,我不知道我是否应该忽略它们或对头文件进行一些更改,以前是否有人遇到过类似的问题?希望有人能给我一些建议,谢谢.示例代码:

 /* gdal_test */#include< iostream>#include< gdal_priv.h>#include< cpl_conv.h>使用命名空间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<<恩德尔cout<<ysize<<恩德尔系统(暂停");返回0;} 

错误列表主要包含以下三个主要问题:

 错误(有效)E0065预期为;"gdaltest C:\ MSVC_Library \ GDAL \ warmerda \ bld \ include C:\ MSVC_Library \ GDAL \ warmerda \ bld \ include \ ogr_geometry.h 387声明为覆盖"的错误(活动)E1455成员函数不会覆盖基类成员gdaltest C:\ MSVC_Library \ GDAL \ warmerda \ bld \ include C:\ MSVC_Library \ GDAL \ warmerda \ bld \ include \ ogr_geometry.h 1139警告C26812枚举类型'CPLErr'未作用域.优先使用枚举类"而不是枚举"(枚举3).gdaltest C:\ MSVC_Library \ GDAL \ warmerda \ bld \ include C:\ MSVC_Library \ GDAL \ warmerda \ bld \ include \ cpl_error.h 244 

我应该更改头文件中的语法吗?会改变它的作用吗?还是我应该忽略这些错误?

解决方案

您声明程序编译,运行和输出正常",因此,正在报告的错误在Visual Studio中使用"

可以按照我对您最近的问题.

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?

解决方案

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.

这篇关于Visual Studio 2019中的GDAL库头文件错误和警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆