I would like to print a debug message for a type (let's say the type is 
'MessageType'), that is not known at compile time. It works fine when 
compiling with gcc, with Visual Studio however I receive the following 
error message:

[libprotobuf WARNING 
...\protobuf-cpp-3.21.9__\protobuf-3.21.9\src\google\protobuf\text_format.cc:2157]
 
Can't print proto content: proto type type.googleapis.com/MessageType not 
found

This is the code I run: 

google::protobuf::Any msg;
msg.ParseFromArray(msg_ptr, msg_size);

std::cout << msg.DebugString() << std::endl;

// parseFromArray<MessageType>( msg_ptr, msg_size ); <-- This is not needed 
when compiling with gcc 

with 

template<typename M>
static M parseFromArray( const void* msg, size_t size )
{
    M result;

    google::protobuf::Any any;
    any.ParseFromArray( msg, static_cast<int>( size ) );
    return parseFromAny<M>( any );
}

So, with Visual Studio I have to parse the any message to the actual 
received type at least once and somewhere (note, that 'parseFromArray' is 
called AFTER DebugString()).

Any ideas/suggestions what to try here?

Thanks in advance!

Tested with
 - Protobuf 3.11.2 and 3.21.9
 - Visual Studio 2022
 - Ubuntu 22 with gcc

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/c800841a-6b22-4ec8-bda7-84d74ce2f2een%40googlegroups.com.

Reply via email to