Question

Compiling on 64-bit Mac w/ -std=gnu++0x gives me the errors:

.../include/utils/common_types.h:93:37: error: reference to non-static member function must be called
    bool valid_min = StringToNumber(min, &min_)
                                    ^~~
.../include/utils/common_types.h:94:43: error: reference to non-static member function must be called
        && Fraction::FromFloatPointString(min, &min_fract_);
                                          ^~~
.../include/utils/common_types.h:95:37: error: reference to non-static member function must be called
    bool valid_max = StringToNumber(max, &max_)
                                    ^~~
.../include/utils/common_types.h:96:43: error: reference to non-static member function must be called
        && Fraction::FromFloatPointString(max, &max_fract_);
                                          ^~~

It compiles fine on 32-bit Ubuntu.

  BasicRange(const std::string& min_str, const std::string& max_str)
      : min_(0),
        max_(0) {
    bool valid_min = StringToNumber(min, &min_)
        && Fraction::FromFloatPointString(min, &min_fract_);
    bool valid_max = StringToNumber(max, &max_)
        && Fraction::FromFloatPointString(max, &max_fract_);
    assert(valid_min && valid_max);
  }
Was it helpful?

Solution 2

Looks like you have min and max as member functions of the class.

Change the code to:

BasicRange(const std::string& min_str, const std::string& max_str)
    : min_(0),
      max_(0) {
  bool valid_min = StringToNumber(min(), &min_)
      && Fraction::FromFloatPointString(min(), &min_fract_);
  bool valid_max = StringToNumber(max(), &max_)
      && Fraction::FromFloatPointString(max(), &max_fract_);
  assert(valid_min && valid_max);
}

OTHER TIPS

I wonder how this code could be compiled on 32-bit Ubuntu.

It seems that the valid code should look the following way

  BasicRange(const std::string& min_str, const std::string& max_str)
      : min_(0),
        max_(0) {
    bool valid_min = StringToNumber(min_str, &min_)
        && Fraction::FromFloatPointString(min_str, &min_fract_);
    bool valid_max = StringToNumber(max_str, &max_)
        && Fraction::FromFloatPointString(max_str, &max_fract_);
    assert(valid_min && valid_max);
  }

That is instead of min and max there must be min_str and max_str

Also it is a very stupid idea to use last underscore in variable names. Do not copy the behaviour of some idiots even if they are well-known.

Your arguments are called min_str and max_str, but in the code below you don't use that, you use min and max. These are presumably getters for the min_ and max_ properties, so when the compiler sees them, it complains that you're referencing member functions without calling them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top