我有一个我无法弄清楚的问题。我使用 OpenEXR 库的项目在 Linux 平台上完美运行。它也必须在 Visual Studio 2015 中可编译。因此我正在尝试移植它。我已经成功编译并安装了 OpenEXR 2.2.0 版本(从官方网站下载,遵循GitHub 上的说明)。不幸的是,我的代码遇到了几个问题。其中一个可以简化为以下小片段:
#include <OpenEXR/ImfInputFile.h>
#include <OpenEXR/ImfHeader.h>
int main(int argc, char * argv[]) {
Imf::InputFile exr_file("test.exr");
const Imf::Header & exr_header = exr_file.header();
// e.g. this fails at debug assertion: map/set iterators incompatible
bool test1 = exr_header.begin() != exr_header.end();
// or this gets stuck somehow and consuming CPU, the program doesn't continue
bool test2 = exr_header.begin() != exr_header.begin();
return 0;
}
当它在发布模式下编译时,它似乎很好(至少对于片段,我的项目还有一些我怀疑相关的其他问题)。但是在我需要调试我的项目的调试模式下,会发生奇怪的事情。第一个测试以调试断言结束:
Debug Assertion Failed!
Program: C:\WINDOWS\SYSTEM32\MSVCP140D.dll
File: c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtree
Line: 326
Expression: map/set iterators incompatible
第二个(当第一个被注释掉时)卡住了,程序似乎处于无限循环中。我不明白为什么。
请问,有人可以帮我吗?如果这很重要,我正在使用 Visual Studio Community 2015。