dannf commented on code in PR #527:
URL: https://github.com/apache/pulsar-client-cpp/pull/527#discussion_r2596466190


##########
lib/ProtobufNativeSchema.cc:
##########
@@ -39,8 +39,8 @@ SchemaInfo createProtobufNativeSchema(const 
google::protobuf::Descriptor* descri
     }
 
     const auto fileDescriptor = descriptor->file();
-    const std::string& rootMessageTypeName = descriptor->full_name();
-    const std::string& rootFileDescriptorName = fileDescriptor->name();
+    const std::string& rootMessageTypeName = 
std::string(descriptor->full_name());
+    const std::string& rootFileDescriptorName = 
std::string(fileDescriptor->name());

Review Comment:
   > Wouldn't the explicit conversion also happen if we don't use a reference 
here?
   Still fails for me:
   
   ```
   diff --git a/lib/ProtobufNativeSchema.cc b/lib/ProtobufNativeSchema.cc
   index 632943d..1d75bd0 100644
   --- a/lib/ProtobufNativeSchema.cc
   +++ b/lib/ProtobufNativeSchema.cc
   @@ -39,8 +39,8 @@ SchemaInfo createProtobufNativeSchema(const 
google::protobuf::Descriptor* descri
        }
    
        const auto fileDescriptor = descriptor->file();
   -    const std::string& rootMessageTypeName = descriptor->full_name();
   -    const std::string& rootFileDescriptorName = fileDescriptor->name();
   +    std::string rootMessageTypeName = descriptor->full_name();
   +    std::string rootFileDescriptorName = fileDescriptor->name();
    
        FileDescriptorSet fileDescriptorSet;
        internalCollectFileDescriptors(fileDescriptor, fileDescriptorSet);
   
   ~ $ VERBOSE=1 cmake --build output
   Change Dir: '/home/build/output'
   
   Run Build Command(s): /usr/bin/ninja -v
   [1/16] /usr/local/bin/c++ -DBOOST_ALLOW_DEPRECATED_HEADERS 
-DBOOST_ALL_NO_LIB -DBUILDING_PULSAR -DHAS_SNAPPY=0 -DHAS_ZSTD=0 
-DPULSAR_AUXV_GETAUXVAL_PRESENT -I/home/build -I/home/build/include 
-I/home/build/output/include -I/home/build/output/generated 
-I/home/build/output/generated/lib -Wno-array-bounds -O3 -DNDEBUG -std=gnu++17 
-fPIC -Wall -Wformat-security -Wvla -Werror -Wno-sign-compare 
-Wno-deprecated-declarations -Wno-error=cpp -msse4.2 -mpclmul 
-fdiagnostics-show-option -fdiagnostics-color -fvisibility=hidden -MD -MT 
lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o -MF 
lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o.d -o 
lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o -c 
/home/build/lib/ProtobufNativeSchema.cc
   ninja: job failed: /usr/local/bin/c++ -DBOOST_ALLOW_DEPRECATED_HEADERS 
-DBOOST_ALL_NO_LIB -DBUILDING_PULSAR -DHAS_SNAPPY=0 -DHAS_ZSTD=0 
-DPULSAR_AUXV_GETAUXVAL_PRESENT -I/home/build -I/home/build/include 
-I/home/build/output/include -I/home/build/output/generated 
-I/home/build/output/generated/lib -Wno-array-bounds -O3 -DNDEBUG -std=gnu++17 
-fPIC -Wall -Wformat-security -Wvla -Werror -Wno-sign-compare 
-Wno-deprecated-declarations -Wno-error=cpp -msse4.2 -mpclmul 
-fdiagnostics-show-option -fdiagnostics-color -fvisibility=hidden -MD -MT 
lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o -MF 
lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o.d -o 
lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o -c 
/home/build/lib/ProtobufNativeSchema.cc
   /home/build/lib/ProtobufNativeSchema.cc: In function 'pulsar::SchemaInfo 
pulsar::createProtobufNativeSchema(const google::protobuf::Descriptor*)':
   /home/build/lib/ProtobufNativeSchema.cc:42:60: error: conversion from 
'absl::lts_20250814::string_view' {aka 'std::basic_string_view<char>'} to 
non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
      42 |     std::string rootMessageTypeName = descriptor->full_name();
         |                                       ~~~~~~~~~~~~~~~~~~~~~^~
   /home/build/lib/ProtobufNativeSchema.cc:43:62: error: conversion from 
'absl::lts_20250814::string_view' {aka 'std::basic_string_view<char>'} to 
non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
      43 |     std::string rootFileDescriptorName = fileDescriptor->name();
         |                                          ~~~~~~~~~~~~~~~~~~~~^~
   ninja: subcommand failed
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to