我正在运行Ubuntu 12.04 LTS并安装了libboost-filesystem1.48-dev。我还将/usr/lib/libboost_filesystem-mt.a包含在我的代码中。我想使用Boost库来检查目录是否存在。添加相应的头文件
#include "boost/filesystem.hpp"
using namespace boost::filesystem;
进入我的程序给了我奇怪的编译错误如下:
22:42:22 **** Incremental Build of configuration gcc-debug for project VENTOS ****
make MODE=debug CONFIGNAME=gcc-debug all
cd application && make all
make[1]: Entering directory `/home/mani/Desktop/VENTOS/application'
Global_03_Statistics.cc
In file included from /usr/include/boost/filesystem/v3/path_traits.hpp:23:0,
from /usr/include/boost/filesystem/v3/path.hpp:25,
from /usr/include/boost/filesystem.hpp:35,
from ./Global_01_TraCI_Extend.h:12,
from ./Global_03_Statistics.h:13,
from Global_03_Statistics.cc:2:
/usr/include/boost/system/error_code.hpp:188:45: error: expected ‘)’
/usr/include/boost/system/error_code.hpp:188:45: error: expected ‘)’
/usr/include/boost/system/error_code.hpp:188:45: error: expected ‘;’ at end of member declaration
/usr/include/boost/system/error_code.hpp:188:45: error: cannot declare member function ‘cSimulation::getActiveEnvir’ within ‘boost::system::error_category’
/usr/include/boost/system/error_code.hpp:188:45: error: expected ‘;’ at end of member declaration
/usr/include/boost/system/error_code.hpp:188:45: error: expected unqualified-id before ‘)’ token
/usr/include/boost/system/error_code.hpp:189:61: error: expected ‘)’
/usr/include/boost/system/error_code.hpp:189:61: error: expected ‘)’
/usr/include/boost/system/error_code.hpp:189:61: error: expected ‘;’ at end of member declaration
/usr/include/boost/system/error_code.hpp:189:61: error: cannot declare member function ‘cSimulation::getActiveEnvir’ within ‘boost::system::error_category’
/usr/include/boost/system/error_code.hpp:189:61: error: expected ‘;’ at end of member declaration
/usr/include/boost/system/error_code.hpp:189:61: error: expected unqualified-id before ‘)’ token
/usr/include/boost/system/error_code.hpp: In member function ‘std::string boost::system::error_condition::message() const’:
/usr/include/boost/system/error_code.hpp:263:79: error: passing ‘const boost::system::error_category’ as ‘this’ argument of ‘virtual std::string boost::system::error_category::message(...)’ discards qualifiers [-fpermissive]
/usr/include/boost/system/error_code.hpp: In member function ‘boost::system::error_condition boost::system::error_code::default_error_condition() const’:
/usr/include/boost/system/error_code.hpp:349:111: error: passing ‘const boost::system::error_category’ as ‘this’ argument of ‘virtual boost::system::error_condition boost::system::error_category::default_error_condition(...)’ discards qualifiers [-fpermissive]
/usr/include/boost/system/error_code.hpp: In member function ‘std::string boost::system::error_code::message() const’:
/usr/include/boost/system/error_code.hpp:350:79: error: passing ‘const boost::system::error_category’ as ‘this’ argument of ‘virtual std::string boost::system::error_category::message(...)’ discards qualifiers [-fpermissive]
/usr/include/boost/system/error_code.hpp: At global scope:
/usr/include/boost/system/error_code.hpp:485:73: error: ‘boost::system::error_category::default_error_condition’ declared as an ‘inline’ variable
/usr/include/boost/system/error_code.hpp:485:73: error: ‘boost::system::error_condition boost::system::error_category::default_error_condition’ is not a static member of ‘class boost::system::error_category’
/usr/include/boost/system/error_code.hpp:485:73: error: invalid cast from type ‘cEnvir’ to type ‘int’
/usr/include/boost/system/error_code.hpp:485:78: error: expected ‘,’ or ‘;’ before ‘const’
/usr/include/boost/system/error_code.hpp: In member function ‘virtual bool boost::system::error_category::equivalent(int, const boost::system::error_condition&) const’:
/usr/include/boost/system/error_code.hpp:493:44: error: passing ‘const boost::system::error_category’ as ‘this’ argument of ‘virtual boost::system::error_condition boost::system::error_category::default_error_condition(...)’ discards qualifiers [-fpermissive]
In file included from /usr/include/boost/filesystem/v3/path.hpp:27:0,
from /usr/include/boost/filesystem.hpp:35,
from ./Global_01_TraCI_Extend.h:12,
from ./Global_03_Statistics.h:13,
from Global_03_Statistics.cc:2:
/usr/include/boost/system/system_error.hpp: At global scope:
/usr/include/boost/system/system_error.hpp:36:25: error: expected ‘)’
/usr/include/boost/system/system_error.hpp:36:25: error: expected ‘)’
/usr/include/boost/system/system_error.hpp:36:25: error: expected ‘;’ at end of member declaration
/usr/include/boost/system/system_error.hpp:36:25: error: cannot declare member function ‘cSimulation::getActiveEnvir’ within ‘boost::system::system_error’
/usr/include/boost/system/system_error.hpp:36:25: error: expected ‘;’ at end of member declaration
/usr/include/boost/system/system_error.hpp:36:25: error: expected unqualified-id before ‘)’ token
/usr/include/boost/system/system_error.hpp:39:25: error: expected ‘)’
/usr/include/boost/system/system_error.hpp:39:25: error: expected ‘)’
/usr/include/boost/system/system_error.hpp:39:25: error: expected ‘;’ at end of member declaration
/usr/include/boost/system/system_error.hpp:39:7: error: ‘boost::system::system_error::system_error(...)’ cannot be overloaded
/usr/include/boost/system/system_error.hpp:36:7: error: with ‘boost::system::system_error::system_error(...)’
/usr/include/boost/system/system_error.hpp:39:25: error: cannot declare member function ‘cSimulation::getActiveEnvir’ within ‘boost::system::system_error’
/usr/include/boost/system/system_error.hpp:39:25: error: expected ‘;’ at end of member declaration
/usr/include/boost/system/system_error.hpp:39:25: error: expected unqualified-id before ‘)’ token
/usr/include/boost/system/system_error.hpp:43:25: error: expected ‘)’
/usr/include/boost/system/system_error.hpp:43:25: error: expected ‘)’
/usr/include/boost/system/system_error.hpp:43:25: error: expected ‘;’ at end of member declaration
/usr/include/boost/system/system_error.hpp:43:7: error: ‘boost::system::system_error::system_error(...)’ cannot be overloaded
/usr/include/boost/system/system_error.hpp:36:7: error: with ‘boost::system::system_error::system_error(...)’
/usr/include/boost/system/system_error.hpp:43:25: error: cannot declare member function ‘cSimulation::getActiveEnvir’ within ‘boost::system::system_error’
/usr/include/boost/system/system_error.hpp:43:25: error: expected ‘;’ at end of member declaration
/usr/include/boost/system/system_error.hpp:43:25: error: expected unqualified-id before ‘)’ token
In file included from /usr/include/boost/filesystem/v3/path_traits.hpp:22:0,
from /usr/include/boost/filesystem/v3/path.hpp:25,
from /usr/include/boost/filesystem.hpp:35,
from ./Global_01_TraCI_Extend.h:12,
from ./Global_03_Statistics.h:13,
from Global_03_Statistics.cc:2:
/usr/include/boost/type_traits/decay.hpp: In instantiation of ‘boost::decay<Eigen::<anonymous enum> >’:
../eigen-3.2.1/Eigen/src/Core/GenericPacketMath.h:289:18: instantiated from here
/usr/include/boost/type_traits/decay.hpp:28:66: error: ‘Eigen::<anonymous enum>’ is/uses anonymous type
/usr/include/boost/type_traits/decay.hpp:28:66: error: trying to instantiate ‘template<class T> struct boost::remove_reference’
/usr/include/boost/type_traits/decay.hpp:38:17: error: ‘Eigen::<anonymous enum>’ is/uses anonymous type
/usr/include/boost/type_traits/decay.hpp:38:17: error: trying to instantiate ‘template<class T> struct boost::remove_reference’
/usr/include/boost/type_traits/decay.hpp: In instantiation of ‘boost::decay<Eigen::<anonymous enum> >’:
../eigen-3.2.1/Eigen/src/Core/Assign.h:71:36: instantiated from here
/usr/include/boost/type_traits/decay.hpp:28:66: error: ‘Eigen::<anonymous enum>’ is/uses anonymous type
/usr/include/boost/type_traits/decay.hpp:28:66: error: trying to instantiate ‘template<class T> struct boost::remove_reference’
/usr/include/boost/type_traits/decay.hpp:38:17: error: ‘Eigen::<anonymous enum>’ is/uses anonymous type
/usr/include/boost/type_traits/decay.hpp:38:17: error: trying to instantiate ‘template<class T> struct boost::remove_reference’
/usr/include/boost/type_traits/decay.hpp: In instantiation of ‘boost::decay<Eigen::<anonymous enum> >’:
../eigen-3.2.1/Eigen/src/Core/util/BlasUtil.h:128:35: instantiated from here
/usr/include/boost/type_traits/decay.hpp:28:66: error: ‘Eigen::<anonymous enum>’ is/uses anonymous type
/usr/include/boost/type_traits/decay.hpp:28:66: error: trying to instantiate ‘template<class T> struct boost::remove_reference’
/usr/include/boost/type_traits/decay.hpp:38:17: error: ‘Eigen::<anonymous enum>’ is/uses anonymous type
/usr/include/boost/type_traits/decay.hpp:38:17: error: trying to instantiate ‘template<class T> struct boost::remove_reference’
/usr/include/boost/type_traits/decay.hpp: In instantiation of ‘boost::decay<Eigen::<anonymous enum> >’:
../eigen-3.2.1/Eigen/src/Core/DiagonalProduct.h:29:86: instantiated from here
/usr/include/boost/type_traits/decay.hpp:28:66: error: ‘Eigen::<anonymous enum>’ is/uses anonymous type
/usr/include/boost/type_traits/decay.hpp:28:66: error: trying to instantiate ‘template<class T> struct boost::remove_reference’
/usr/include/boost/type_traits/decay.hpp:38:17: error: ‘Eigen::<anonymous enum>’ is/uses anonymous type
/usr/include/boost/type_traits/decay.hpp:38:17: error: trying to instantiate ‘template<class T> struct boost::remove_reference’
/usr/include/boost/type_traits/decay.hpp: In instantiation of ‘boost::decay<Eigen::<anonymous enum> >’:
../eigen-3.2.1/Eigen/src/Core/IO.h:168:23: instantiated from here
/usr/include/boost/type_traits/decay.hpp:28:66: error: ‘Eigen::<anonymous enum>’ is/uses anonymous type
/usr/include/boost/type_traits/decay.hpp:28:66: error: trying to instantiate ‘template<class T> struct boost::remove_reference’
/usr/include/boost/type_traits/decay.hpp:38:17: error: ‘Eigen::<anonymous enum>’ is/uses anonymous type
/usr/include/boost/type_traits/decay.hpp:38:17: error: trying to instantiate ‘template<class T> struct boost::remove_reference’
/usr/include/boost/type_traits/decay.hpp: In instantiation of ‘boost::decay<Eigen::<anonymous enum> >’:
../eigen-3.2.1/Eigen/src/Core/TriangularMatrix.h:102:7: instantiated from here
/usr/include/boost/type_traits/decay.hpp:28:66: error: ‘Eigen::<anonymous enum>’ is/uses anonymous type
/usr/include/boost/type_traits/decay.hpp:28:66: error: trying to instantiate ‘template<class T> struct boost::remove_reference’
/usr/include/boost/type_traits/decay.hpp:38:17: error: ‘Eigen::<anonymous enum>’ is/uses anonymous type
/usr/include/boost/type_traits/decay.hpp:38:17: error: trying to instantiate ‘template<class T> struct boost::remove_reference’
/usr/include/boost/type_traits/decay.hpp: In instantiation of ‘boost::decay<Eigen::internal::<anonymous enum> >’:
../eigen-3.2.1/Eigen/src/SVD/JacobiSVD.h:41:28: instantiated from here
/usr/include/boost/type_traits/decay.hpp:28:66: error: ‘Eigen::internal::<anonymous enum>’ is/uses anonymous type
/usr/include/boost/type_traits/decay.hpp:28:66: error: trying to instantiate ‘template<class T> struct boost::remove_reference’
/usr/include/boost/type_traits/decay.hpp:38:17: error: ‘Eigen::internal::<anonymous enum>’ is/uses anonymous type
/usr/include/boost/type_traits/decay.hpp:38:17: error: trying to instantiate ‘template<class T> struct boost::remove_reference’
Global_03_Statistics.cc: In member function ‘int Statistics::getNodeIndex(const char*)’:
Global_03_Statistics.cc:486:33: warning: NULL used in arithmetic [-Wpointer-arith]
make[1]: Leaving directory `/home/mani/Desktop/VENTOS/application'
make[1]: *** [../out/gcc-debug/application/Global_03_Statistics.o] Error 1
make: *** [application_dir] Error 2
错误位于
的error_code.hpp文件中virtual std::string message( int ev ) const = 0;
单击ev,将我带到cenvir.h文件,该文件由OMNET ++模拟器(我正在编码的模拟器)定义。在此标题中,ev定义为
#define ev (*cSimulation::getActiveEnvir())