错误:命名构造函数,而不是类型.使用g++4.6.1编译时

Error : names the constructor, not the type. while compiling with g++4.6.1

本文关键字:g++4 使用 类型 编译 构造函数 错误      更新时间:2023-10-16

我在aix6.1上用g++4.6.1编译代码,得到这个错误:-

ViaChecks.h:14:3: error: 'BuPolygonEX<AllPass<CornerT<NetAndVal<ZVal3> > > >::IOPS::Base {aka BuPolygonCore<bu_polygon_clean_func, no_derivatives, AllPass<CornerT<NetAndVal<ZVal3> > > >::IOPS}::IOPS' names the constructor, not the type

结构定义为:

struct ViaSquareCheck : BuPolygonEX<AllPass<CornerT<NetAndVal<ZVal3> > > > {
  typedef BuPolygonEX<AllPass<CornerT<NetAndVal<ZVal3> > > > Base;
  DEFINE_ENGINE_PROPERTIES_INHERIT(Base::IOPS, void update() { Base::update(); i().xregion_1nm_oversize(x0nm); o().xregion_1nm_oversize(x0nm); o().derivatives(x_dom); o().bu_polygonized(yes); }); // via_square_dim property is added inside
  membert(int, amount, -1, ViaSquareCheck);
  ViaSquareCheck();
  ViaSquareCheck* output(DFC* dfc) { return set_output(0,dfc); } // single output returns good vias
  ViaSquareCheck* set_output(int k, DFC* dfc);
  void option(const string& pname, const string& pval); // some options change engine properties
private:
  BadViaMultiplexer<C>* mux;
  GIM2a<APC> bad_via_gim;
  GIM2a<APC> good_via_gim;
  member(bool, linked, false);
  member(bool, ok_45, false);
  void link();
  member(ViaSquareCheckNetProcess*, np,NULL);
};

DEFINE_ENGINE_PROPERTIES_INHERIT的定义:-

#define DEFINE_ENGINE_PROPERTIES_INHERIT(SSSS, extras...) 
struct IOPS : SSSS { 
      EnginePropertiesVector& i() { return SSSS::i(); }; 
      EnginePropertiesVector& o() { return SSSS::o(); }; 
      EngineProperties& i(int n) { return SSSS::i(n); }; 
      EngineProperties& o(int n) { return SSSS::o(n); }; 
      typedef SSSS Base; 
      extras; } ep_; 

谢谢。

如果使用名称

,则给出此诊断。
myclass::myclass

此名称不表示类myclass,而是表示它的构造函数

这是一个像Base::IOPS,这样的限定名称,我们需要在此之前有一个typename。您需要传递一个类型而不是限定名Base::IOPS,因此我定义了一个类型

typedef Base::IOPS MYIOP 

,然后传递该类型,因此错误"this is not a type"就消失了。

你应该用类似

的东西预处理你的源代码
g++ -C -E yoursource.cc | grep -v '^#' > yoursource.ii

(grep -v删除行编号)

然后用

编译预处理后的表单
g++ -Wall -c yoursource.ii

然后查看yoursource.ii

中错误消息的位置

你也可以问gcc-help@gcc.gnu.org

但是正如其他人指出的,你的代码不是很漂亮…

当你说:

DEFINE_ENGINE_PROPERTIES_INHERIT(Base::IOPS, ...  

你应该写:

DEFINE_ENGINE_PROPERTIES_INHERIT(Base, ...  

即没有::IOPS