png ++无效的模板参数Eclipse编辑器Cygwin符号链接 [英] png++ invalid template arguments Eclipse editor Cygwin symbolic link

查看:807
本文介绍了png ++无效的模板参数Eclipse编辑器Cygwin符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Eclipse CDT与 Cygwin GCC 工具链,以便使用png ++读取一些图像。我已经安装了png ++头(我试过两个0.2.5和0.2.7)在我的Cygwin,它编译良好使用外部构建器设置与make,但由于某种原因,编辑器下划线从png :: image的图像非常简单的代码:

  #include< png ++ / png.hpp> 

int main(int argc,char * argv []){
png :: image< png :: gray_pixel> t(128,128);
return 1;
}

出现错误:


模板参数无效。


我看了一下这个错误,对于其他人来说,是由于没有将GCC设置为使用C ++ 11引起的(例如地图上的模板参数无效std :: map< std :: string,Stock *>& stocks ),但我不认为这是一个问题,因为我有我CDT GCC内置编译器设置Cygwin提供程序命令设置为:



$ {COMMAND} $ {FLAGS} -E -P -v -dD -std = c ++ 11$ {INPUTS}



并且 std :: normal_distribution< ; double>



我可以通过关闭无效的模板参数来删除错误下划线项目属性 - > - > - >代码分析,但是问题比这更深,因为没有自动完成将适用于类型的对象png :: image,如果我尝试在一个函数中使用它,例如:

  void pngTest(png :: image< ; png :: gray_pixel> im,int other){} 

$ c>无效的参数'Candidates are:void pngTest(?,int)'



所以看来它不能解决类型。这可能是什么原因导致的?

解决方案

原来这不是一个Eclipse解析的错误,但与Cygwin风格的符号链接不兼容。在png ++的 png.hpp types.hpp 中包含 png.h 从libpng,但在Cygwin中png.h(在/ usr / include)是一个Cygwin风格的符号链接到当前libpng(在我的情况下,文件包含文本:!< symlink> libpng16 /png.h )。



所以Eclipse无法解决这个问题,即使Cygwin的GCC可以,它正在使types.hpp中的typedef无法正确解决。这是为什么我在eclipse中得到无效的模板参数错误, png :: gray_pixel 不是一个有效的类型。我注意到,当我把< int> ,而不再给错误。这就是问题。



我将包含路径从 png.h 更改为 libpng16 / png png.hpp types.hpp p>

现在eclipse中的所有东西在右键单击项目 - > - > 重建后正确解析。或者,您可以符号链接 png.h pngconf.h pnglibconf.h <



如果任何人都知道Eclipse的方法,那么可以使用windows mklink命令将$ usr / include加到适当的libpng子文件夹中。与Cygwin符号链接无缝工作,然后在这里发布,我将接受作为答案,因为显然是比这个hacky修复更好一点。



谢谢你们的评论,但似乎幸运的是,这一次它不是一个Eclipse问题。


I am trying to use Eclipse CDT with the Cygwin GCC toolchain in order to read in some images using png++. I have installed the png++ headers (I tried both 0.2.5 and 0.2.7) in my Cygwin, and it compiles fine using the external builder settings with make, but for some reason the editor underlines "image" from png::image in the very simple code:

#include <png++/png.hpp>

int main( int argc, char* argv[]){
    png::image<png::gray_pixel> t(128,128);
    return 1;
}

And gives the error:

Invalid template arguments.

I looked around a bit for this error, and it seems for other people it was caused by not having GCC set to use C++11 (such as Invalid template arguments on map std::map< std::string, Stock*> &stocks), but I do not think that is an issue with me, since I have my "CDT GCC Built-in Compiler Settings Cygwin" provider command set to:

${COMMAND} ${FLAGS} -E -P -v -dD -std=c++11 "${INPUTS}"

And the line std::normal_distribution<double> distribution(5.0,2.0); does not give an error.

I can remove the error underline by turning off "Invalid template argument" under the project properties -> C/C++ General -> Code Analysis, but the problem is deeper than that, as none of the auto-completes will work for the object of type png::image, and if I try and use it in a function, for example:

void pngTest(png::image<png::gray_pixel> im, int other) {}

it gives the error: Invalid arguments ' Candidates are: void pngTest(?, int) '

So it seems it does not resolve the type at all. What might be causing this?

解决方案

Turns out this was not actually a bug with Eclipse parsing, but an incompatibility with Cygwin style symlinks. In png++'s png.hpp and types.hpp it includes png.h from libpng, but in Cygwin png.h (in /usr/include) is a Cygwin style symlink to the current libpng (in my case the file contained the text: !<symlink>libpng16/png.h).

So Eclipse could not resolve this include, even though Cygwin's GCC could, and it was making the typedefs in types.hpp not resolve correctly. This is why I was getting an invalid template arguments error in eclipse, png::gray_pixel was not a valid type. I noticed this when I put <int> instead and it no longer gave an error. So that was the problem.

I changed the include paths from png.h to libpng16/png.h in both png.hpp and types.hpp

and now everything in eclipse is resolving correctly after a right click on the project -> index -> rebuild. Alternatively you could symlink png.h, pngconf.h, and pnglibconf.h in /usr/include to the appropriate libpng subfolder using the windows mklink command and remove the Cygwin style symlinks.

If anyone knows a way for Eclipse to work seamlessly with Cygwin symlinks then post here and I will accept that as the answer, since obviously that is a little better than this hacky fix.

Thank you guys for the comments, but it seems thankfully that this time it was not an Eclipse issue.

这篇关于png ++无效的模板参数Eclipse编辑器Cygwin符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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