在C ++中读取HDF5表 - 编译数据结构时出错

时间:2013-02-16 06:22:08

标签: c++ llvm hdf5 llvm-clang

我试图用C ++中的HDF5文件读取。试图为表定义数据结构:

struct LandE{

  enum {nFields = 7};

  double Luminosity_nue;
  double Luminosity_nuebar;
  double Luminosity_nux;
  double Mean_Energy_nue;
  double Mean_Energy_nuebar;
  double Mean_Energy_nux;
  double Post_Bounce_Time;


  static const size_t( &getOffsets() )[nFields]{

    const static size_t offsets[nFields] = {

      HOFFSET(LandE, Luminosity_nue),
      HOFFSET(LandE, Luminosity_nuebar),
      HOFFSET(LandE, Luminosity_nux),
      HOFFSET(LandE, Mean_Energy_nue),
      HOFFSET(LandE, Mean_Energy_nuebar),
      HOFFSET(LandE, Mean_Energy_nux),
      HOFFSET(LandE, Post_Bounce_Time)

    };

  return(offsets);

  }

  static const size_t( &getSizes() )[nFields]{

    const static size_t sizes[nFields] = {

      sizeof(Luminosity_nue),
      sizeof(Luminosity_nuebar),
      sizeof(Luminosity_nux),
      sizeof(Mean_Energy_nue),
      sizeof(Mean_Energy_nuebar),
      sizeof(Mean_Energy_nux),
      sizeof(Post_Bounce_Time)

    };

    return(sizes);

  }

  static const char* getFields(){
    return("Luminosity_nue,Luminosity_nuebar,Luminosity_nux,Mean_Energy_nue,Mean_Energy_nuebar,Mean_Energy_nux,Post_Bounce_Time");
  }

};

我收到错误

invalid use of member 'Luminosity_nue' in static member function

用于所有sizeof()命令。

我不确定是什么问题,因为我看过类似的代码编译。

提前多多感谢。

编译的代码:

struct LLHParamsRecord{
        enum {nFields=(RecordBase::nFields+2)};

        RecordBase base;
        double logl;
        int ndof;

        static const size_t(&getOffsets())[nFields]{
                const static size_t offsets[nFields] = {
                        HOFFSET(LLHParamsRecord, base.run),
                        HOFFSET(LLHParamsRecord, base.event),
                        HOFFSET(LLHParamsRecord, base.subEvent),
                        HOFFSET(LLHParamsRecord, base.subEventStream),
                        HOFFSET(LLHParamsRecord, base.exists),
                        HOFFSET(LLHParamsRecord, logl),
                        HOFFSET(LLHParamsRecord, ndof)
                };
                return(offsets);
        }
        static const size_t(&getSizes())[nFields]{
                const static size_t sizes[nFields] = {
                        sizeof(RecordBase::run),
                        sizeof(RecordBase::event),
                        sizeof(RecordBase::subEvent),
                        sizeof(RecordBase::subEventStream),
                        sizeof(RecordBase::exists),
                        sizeof(logl),
                        sizeof(ndof)
                };
                return(sizes);
        }

        static const char* getFields(){
                return("Run,Event,SubEvent,SubEventStream,exists,logl,ndof");
        }
};

其中RecordBase是另一个类似的结构。

0 个答案:

没有答案