Visual Studio 2015 compiler issue

24 views
Skip to first unread message

Bill Leisge

unread,
Jun 11, 2021, 6:54:56 PM6/11/21
to Protocol Buffers
I am having a odd issue with a GPB message containing an Optional field of type float.  The VS compiler generates inline function for the set_variable() referencing this+16h and the get function variable() referencing this+18h.  Changing the .proto field type to uint32 gave the same result.  Any help here would be greatly appreciated.  Thank you

Bill Leisge

unread,
Jun 12, 2021, 4:27:56 PM6/12/21
to Protocol Buffers
Looking back on my post, I need to add additional context.  The message of containing the variable in question is...

message GeneratorStatus {
    optional int32 command = 1;
    optional bool is_generator_on = 2;
    optional bool is_generator_busy = 3;
    optional float current = 4;
}

The following encode the GeneratorStatus message...
    pGeneratorStatus->set_current(4.5);
    if (pGeneratorStatus->has_current())
        float CurrentReadback = pGeneratorStatus->current();

CurrentReadback is a very small number, certainly not 4.5.

Tracing into the Protec .h file the disassembled function _internal_set_current() the AX register is set to the instance of pGeneratorStatus (this pointer)  and stores the argument at AX+16h.  Similarly the getter function _internal_current() set AX to the this pointer and sets the destination register to AX+18h.  The GeneratorStatus object member _current is a float and the generated code leading up to setting _current is correct, it is only the operand references that are not correct.

I have changed the scalar to double and uint32 to no avail.

It is obvious not a proto/Protec issue in that the generated C++ code is correct, but VS 2015 code generation anomaly.

I am hoping a group member has experienced this issue and might have a solution. Thank you.



Adam Cozzette

unread,
Jun 18, 2021, 6:43:54 PM6/18/21
to Bill Leisge, Protocol Buffers
I would guess that there is some kind of mismatch in your protobuf generated code. This kind of thing might happen if perhaps you added a new field and updated the pb.cc file but not the pb.h file (or vice versa).

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/6c41448b-4659-4c6e-ac8b-c2bf30830047n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages