为shared_array.hpp增加编译错误

时间:2018-03-07 10:14:54

标签: boost

#ifndef __NSFOCUS_URL_RULE_H__
#define __NSFOCUS_URL_RULE_H__
#include "engine/packet.h"
#include "engine/firewall/FireWall.h"
#include "include/DomParser.h"
#include <string>
#include <vector>
#include <boost/shared_array.hpp>

namespace nsfocus
{

class UrlRule : public FireWallRuleBase
{
private:
        std::set<int> m_cats;            
        unsigned int m_url_action;                                 
        bool CheckURLCat(Packet& p, std::string& 
category,boost::shared_array<unsigned short>& pCatID,unsigned short& nSize);

public:
        UrlRule(void) : FireWallRuleBase(), m_url_action(0x4000) {}
        virtual ~UrlRule(void) {}
        virtual void Parse(xercesc::DOMNode* node);
        void ParseNoFwInfo(xercesc::DOMNode* node);
        void ParseFwInfo(xercesc::DOMNode* node);
        virtual bool isMatch(Packet& p, std::string& 
category,boost::shared_array<unsigned short>& pCatID,unsigned short& nSize);
        virtual bool isProfileMatch(Packet& p, std::string& 
category,boost::shared_array<unsigned short>& pCatID,unsigned short& nSize);
        unsigned int GetAction(void)
        {
                return m_url_action;
        }
};

} 

#endif 

错误:

In file included from /usr/include/boost/core/demangle.hpp:29:0,
                 from /usr/include/boost/core/typeinfo.hpp:119,
                 from /usr/include/boost/detail/sp_typeinfo.hpp:20,
                 from /usr/include/boost/smart_ptr/detail/sp_counted_base_sync.hpp:18,
                 from /usr/include/boost/smart_ptr/detail/sp_counted_base.hpp:72,
                 from /usr/include/boost/smart_ptr/detail/shared_count.hpp:29,
                 from /usr/include/boost/smart_ptr/shared_ptr.hpp:28,
                 from /usr/include/boost/smart_ptr/shared_array.hpp:24,
                 from /usr/include/boost/shared_array.hpp:17,
                 from aclass/engine/firewall/UrlRule.h:17,
                 from aclass/engine/firewall/FirewallCtrl.h:14,
                 from aclass/class_main.cpp:23:
/usr/include/c++/5.1.1/cxxabi.h: At global scope:
/usr/include/c++/5.1.1/cxxabi.h:214:3: error: expected class-name before '{' token
   {
   ^
/usr/include/c++/5.1.1/cxxabi.h: In constructor '__cxxabiv1::__fundamental_type_info::__fundamental_type_info(const char*)':
/usr/include/c++/5.1.1/cxxabi.h:217:62: error: expected class-name before '(' token
     __fundamental_type_info(const char* __n) : std::type_info(__n) { }
                                                              ^
/usr/include/c++/5.1.1/cxxabi.h:217:62: error: expected '{' before '(' token
/usr/include/c++/5.1.1/cxxabi.h: At global scope:
/usr/include/c++/5.1.1/cxxabi.h:225:3: error: expected class-name before '{' token
   {
   ^
/usr/include/c++/5.1.1/cxxabi.h: In constructor '__cxxabiv1::__array_type_info::__array_type_info(const char*)':
/usr/include/c++/5.1.1/cxxabi.h:228:56: error: expected class-name before '(' token
     __array_type_info(const char* __n) : std::type_info(__n) { }

enter image description here

2 个答案:

答案 0 :(得分:0)

/usr/include/c++/5.1.1/cxxabi.h: At global scope:
/usr/include/c++/5.1.1/cxxabi.h:214:3: error: expected class-name before '{' token
   {
   ^
/usr/include/c++/5.1.1/cxxabi.h: In constructor '__cxxabiv1::__fundamental_type_info::__fundamental_type_info(const char*)':
/usr/include/c++/5.1.1/cxxabi.h:217:62: error: expected class-name before '(' token
     __fundamental_type_info(const char* __n) : std::type_info(__n) { }

这些表示以下代码行:

  class __fundamental_type_info : public std::type_info
  {
  public:
    explicit
    __fundamental_type_info(const char* __n) : std::type_info(__n) { }

不编译因为std::type_info不是类型。但是,由于<typeinfo>正好位于其上方,这导致我怀疑您的某个标题包含宏定义,如

#define type_info ...

...可能为空)。

  

我建议检查预处理的来源。

其他数据点

以下代码在我的框中编译正确:

#include <boost/shared_array.hpp>
#include <set>
#include <string>
#include <vector>

#include <xercesc/dom/DOM.hpp>

namespace nsfocus {

struct FireWallRuleBase {};
struct Packet {};

class UrlRule : public FireWallRuleBase {
  private:
    std::set<int> m_cats;
    unsigned int m_url_action;
    bool CheckURLCat(Packet &p, std::string &category, boost::shared_array<unsigned short> &pCatID, unsigned short &nSize);

  public:
    UrlRule(void) : FireWallRuleBase(), m_url_action(0x4000) {}
    virtual ~UrlRule(void) {}
    virtual void Parse(xercesc::DOMNode *node);
    void ParseNoFwInfo(xercesc::DOMNode *node);
    void ParseFwInfo(xercesc::DOMNode *node);
    virtual bool isMatch(Packet &p, std::string &category, boost::shared_array<unsigned short> &pCatID,
                         unsigned short &nSize);
    virtual bool isProfileMatch(Packet &p, std::string &category, boost::shared_array<unsigned short> &pCatID,
                                unsigned short &nSize);
    unsigned int GetAction(void) { return m_url_action; }
};

} // namespace nsfocus

答案 1 :(得分:0)

#include <boost/shared_array.hpp>
#include <set>
#include <string>
#include <vector>
#include <iostream>
//#include <xercesc/dom/DOM.hpp>
//using namespace std;
namespace nsfocus {

struct FireWallRuleBase {};
struct Packet {};

class UrlRule : public FireWallRuleBase {
private:
std::set<int> m_cats;
unsigned int m_url_action;
bool CheckURLCat(Packet &p, std::string &category, 
boost::shared_array<unsigned short> &pCatID, unsigned short &nSize);

public:
UrlRule(void) : FireWallRuleBase(), m_url_action(0x4000) {}
virtual ~UrlRule(void) {}
//virtual void Parse(xercesc::DOMNode *node);
//void ParseNoFwInfo(xercesc::DOMNode *node);
//void ParseFwInfo(xercesc::DOMNode *node);
virtual bool isMatch(Packet &p, std::string &category, 
boost::shared_array<unsigned short> &pCatID,
                     unsigned short &nSize);
    virtual bool isProfileMatch(Packet &p, std::string &category, 
boost::shared_array<unsigned short> &pCatID,
                            unsigned short &nSize);
    unsigned int GetAction(void) { return m_url_action; }
};

} // namespace nsfocus

enter image description here