HuaHuaY commented on code in PR #194:
URL: https://github.com/apache/iceberg-cpp/pull/194#discussion_r2314836523


##########
src/iceberg/util/macros.h:
##########
@@ -19,10 +19,13 @@
 
 #pragma once
 
-#define ICEBERG_RETURN_UNEXPECTED(result)          \
-  if (!result) [[unlikely]] {                      \
-    return std::unexpected<Error>(result.error()); \
-  }
+#define ICEBERG_RETURN_UNEXPECTED(result)                 \
+  do {                                                    \
+    auto&& result_name = (result);                        \
+    if (!result_name) [[unlikely]] {                      \
+      return std::unexpected<Error>(result_name.error()); \
+    }                                                     \
+  } while (false);

Review Comment:
   #define ICEBERG_RETURN_UNEXPECTED(result)                         \
     if (auto&& result_name = result; !result_name) [[unlikely]] { \
       return std::unexpected<Error>(result_name.error());           \
     }



##########
src/iceberg/util/macros.h:
##########
@@ -19,10 +19,13 @@
 
 #pragma once
 
-#define ICEBERG_RETURN_UNEXPECTED(result)          \
-  if (!result) [[unlikely]] {                      \
-    return std::unexpected<Error>(result.error()); \
-  }
+#define ICEBERG_RETURN_UNEXPECTED(result)                 \
+  do {                                                    \
+    auto&& result_name = (result);                        \
+    if (!result_name) [[unlikely]] {                      \
+      return std::unexpected<Error>(result_name.error()); \
+    }                                                     \
+  } while (false);

Review Comment:
   #define ICEBERG_RETURN_UNEXPECTED(result)                         \
     if (auto&& result_name = result; !result_name) [[unlikely]] { \
       return std::unexpected<Error>(result_name.error());           \
     }



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to