我是新手,我试着用isomorphism.hpp文件来绘制有向图。
在试图运行代码时,在boost库文件中我看到了错误
1>c:\boost_1_55_0\boost\graph\isomorphism.hpp(142):error C4703:可能未初始化的本地指针变量“v”使用 1>c:\boost_1_55_0\boost\graph\isomorphism.hpp(147):error C4703:可能未初始化的本地指针变量“v”使用
从这里被扔出去了,
BGL_FORALL_VERTICES_T(v, G1, Graph1){
f[v] = graph_traits<Graph2>::null_vertex(); //error thrown here
}这在boost/graphs/iteration_macs.hpp中有定义,如下所示:
#define BGL_FORALL_VERTICES_T(VNAME, GNAME, GraphType) \
for (std::pair<typename boost::graph_traits<GraphType>::vertex_iterator, \
typename boost::graph_traits<GraphType>::vertex_iterator> BGL_RANGE(__LINE__) = vertices(GNAME); \
BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
for (typename boost::graph_traits<GraphType>::vertex_descriptor VNAME; \
BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) ? (VNAME = *BGL_FIRST(__LINE__), true):false; \
++BGL_FIRST(__LINE__))我们需要在哪里定义这个?这是众所周知的问题吗?
发布于 2014-04-16 02:03:43
1>c:\boost_1_55_0\boost\graph\isomorphism.hpp(142):error C4703:可能未初始化的本地指针变量“v”使用
给予..。
BGL_FORALL_VERTICES_T(v, G1, Graph1)...and...
#define BGL_FORALL_VERTICES_T(VNAME, GNAME, GraphType)...we知道v在宏中称为VNAME。
外循环的条件是:
BGL_FIRST(__LINE__) != BGL_LAST(__LINE__)内环的条件是:
BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) ? (VNAME = *BGL_FIRST(__LINE__), true):false;如果内环不运行,除非满足外部循环条件,我们可以简化:
true ? (VNAME = *BGL_FIRST(__LINE__), true):false;
(VNAME = *BGL_FIRST(__LINE__), true) ;显然,VNAME总是被分配给并且从未使用未经初始化。您的编译器的分析是有缺陷的,您应该禁用警告(如果有可能的话,只针对这个特定的代码),否则关闭任何把警告作为错误的编译器选项,这样您的构建就不会完全崩溃,或者尝试另一个编译器。
发布于 2019-07-21 22:00:29
去
Project > "ProjectName" Properties > C/C++ > General在那里,您应该将"SDL检查“从Yes切换到No。
发布于 2019-12-14 04:36:01
VisualStudio2019(平台工具集v142)启用了C++20,警告级别4提供了很多警告。使他们沉默:
#pragma warning(push)
#pragma warning(disable: 4244) // '-=': conversion from '__int64' to 'int', possible loss of data
#pragma warning(disable: 4267) // '=' : conversion from 'size_t' to 'int', possible loss of data
#pragma warning(disable: 4456) // declaration of 'xxx' hides previous local declaration
#pragma warning(disable: 4701) // potentially uninitialized local variable 'xxx' used
#pragma warning(disable: 4703) // potentially uninitialized local pointer variable 'xxx' used
#include <boost/graph/isomorphism.hpp>
#pragma warning(pop)https://stackoverflow.com/questions/23097462
复制相似问题