KalleOlaviNiemitalo commented on code in PR #3128:
URL: https://github.com/apache/avro/pull/3128#discussion_r1740582073


##########
lang/c++/impl/avrogencpp.cc:
##########
@@ -739,6 +742,28 @@ void CodeGen::generateTraits(const NodePtr &n) {
     }
 }
 
+void CodeGen::generateDocComment(const NodePtr &n, const char *indent) {
+    if (!n->getDoc().empty()) {
+        std::vector<std::string> lines;
+        boost::algorithm::split(lines, n->getDoc(), 
boost::algorithm::is_any_of("\n"));
+        for (auto &line : lines) {
+            boost::algorithm::replace_all(line, "\r", "");
+
+            if (line.empty()) {
+                os_ << indent << "//\n";
+            } else {
+                // If a comment line ends with a backslash, avoid generating 
code which will generate
+                // multi-line comment warnings on GCC. We can't just append 
whitespace here as escaped
+                // newlines ignore trailing whitespace.
+                if (line.back() == '\\') {
+                    line.append("(backslash)");

Review Comment:
   Yes, it will; the added `(backslash)` will prevent the C++ preprocessor from 
treating the actual backslash as line continuation.
   
   However… if the schema has `"doc": "with trailing backslash and whitespace\\ 
\t"`, then `line.back()` will be `'\t'` and this code won't append anything.  
For GCC compatibility, I think `(backslash)` (or whatever other text is 
decided) should be appended in that case too.



-- 
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