marin-ma commented on PR #8895:
URL: 
https://github.com/apache/incubator-gluten/pull/8895#issuecomment-2896552277

   I got below compilation error with clang
   ```
   In file included from 
/Users/rong/workspace/github/apache/gluten/cpp/core/jni/JniError.cc:17:
   In file included from 
/Users/rong/workspace/github/apache/gluten/cpp/core/jni/JniError.h:22:
   /Users/rong/workspace/github/apache/gluten/cpp/core/jni/JniCommon.h:39:15: 
error: variable length arrays in C++ are a Clang extension 
[-Werror,-Wvla-cxx-extension]
      39 |   char buffer[clen + 1];
         |               ^~~~~~~~
   /Users/rong/workspace/github/apache/gluten/cpp/core/jni/JniCommon.h:39:15: 
note: read of non-const variable 'clen' is not allowed in a constant expression
   /Users/rong/workspace/github/apache/gluten/cpp/core/jni/JniCommon.h:36:17: 
note: declared here
      36 |   int32_t jlen, clen;
         |                 ^
   1 error generated.
   ```
   
   Perhaps it's not a good practice to use variable lengths arrays in the code. 
VLA is not part of the C++ standard.
   
   Here's another implementation in arrow 
https://github.com/apache/arrow-java/blame/main/dataset/src/main/cpp/jni_util.cc#L318-L326
 , which is more clear to use `GetStringUTFChars` and `ReleaseStringUTFChars` 
@jinchengchenghh Do you know if there are any reason we didn't implement it in 
this way?


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to