arashandishgar commented on issue #45808:
URL: https://github.com/apache/arrow/issues/45808#issuecomment-2740182072

   > In general, we can use anonymous namespace but CMake's unity build 
https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html may cause a 
problem with anonymous namespace.
   > 
   > If there are same definitions in anonymous namespaces in different `.cc`, 
it causes a redefinition error with CMake's unity build. We need to use 
`XXX_detail` (or something) namespaces for the case.
   
   I found CMake addressed this issue with [this 
property](https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD_UNIQUE_ID.html#prop_tgt:UNITY_BUILD_UNIQUE_ID).
 However, the way of using it is a bit weird. Let me explain it.
   
   ```
   
   set_target_properties(myTarget PROPERTIES
     UNITY_BUILD "ON"
     UNITY_BUILD_UNIQUE_ID "MY_UID"
   )
   
   ```
   Then MY_UID should be used in the anonymous namespace.
   Finally, CMake generates a unity file like the below code.
   
   ```
   /* generated by CMake */
   
   /* SRC_src/main.cpp */
   #undef MY_UID
   #define MY_UID unity_ab70e1563c03f3f1deca382e6a2a93c7
   /* NOLINTNEXTLINE(bugprone-suspicious-include) */
   #include 
"/media/arashandishgar/7ea4b859-cfd7-41cb-8466-dc8dbc34284b/ARROW/1/src/main.cpp"
   
   /* SRC_src/file1.cpp */
   #undef MY_UID
   #define MY_UID unity_9588e9aa358eed3fe33809f491e750e7
   /* NOLINTNEXTLINE(bugprone-suspicious-include) */
   #include 
"/media/arashandishgar/7ea4b859-cfd7-41cb-8466-dc8dbc34284b/ARROW/1/src/file1.cpp"
   
   /* SRC_src/file2.cpp */
   #undef MY_UID
   #define MY_UID unity_2a7bc4c35d76e69211aac67f88d10888
   /* NOLINTNEXTLINE(bugprone-suspicious-include) */
   #include 
"/media/arashandishgar/7ea4b859-cfd7-41cb-8466-dc8dbc34284b/ARROW/1/src/file2.cpp"
   
   ```
   Does Arrow have such a mechanism?


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