Home > Mobile >  Is repeated google.protobuf.DoubleValue same with repeated double?
Is repeated google.protobuf.DoubleValue same with repeated double?

Time:12-06

I know how to operate repeated double to get value or set value ,but I don't konw how to operate repeated google.protobuf.DoubleValue, I compile repeated google.protobuf.DoubleValue in the way as repeated double, I got error, as if they are different, Suppose they are different,How should I operate repeated google.protobuf.DoubleValue to set value and get value in c ?

proto

message MathData{

repeated google.protobuf.DoubleValue num;

}

c

MathData var;
var.add_num(1.0);

this will compile error with no matching function for call to 'Test::MathData::add_bid(double)

CodePudding user response:

Is repeated google.protobuf.DoubleValue same with repeated double

NO. google::protobuf::DoubleValue is of message type, while double is of builtin type.

google::protobuf::DoubleValue is defined as follows:

message DoubleValue {
  // The double value.
  double value = 1;
}

So you can try the following code:

MathData data;
auto *num = data.add_num();
num->set_value(1.0);
  • Related