Hi, I've noticed that in the C++ version we place everything inside anonymous namespace. While this theoretically makes it easy to maintain header-only design, I believe this actually makes any use of libdivide::divider in a multi-file project potentially ill-defined.
The problem is that, as each translation unit has its own anonymous namespace, in each translation unit we declare a unique class template libdivide::::divide, so we cannot really pass an instance of divider between translation unit.
g++ agrees that something is wrong with this approach by issuing a warning similar to
warning: ‘IntWithDivider’ has a field ‘IntWithDivider::divider’ whose type uses the anonymous namespace [-Wsubobject-linkage]
struct IntWithDivider {
^~~~~~~~~~~~~~
In this pull request I try to address this issue by placing everything in the common libdivide:: namespace, and providing every function with inline specifier.
Hi, I've noticed that in the C++ version we place everything inside anonymous namespace. While this theoretically makes it easy to maintain header-only design, I believe this actually makes any use of libdivide::divider in a multi-file project potentially ill-defined. The problem is that, as each translation unit has its own anonymous namespace, in each translation unit we declare a unique class template libdivide::::divide, so we cannot really pass an instance of divider between translation unit.
g++
agrees that something is wrong with this approach by issuing a warning similar toIn this pull request I try to address this issue by placing everything in the common libdivide:: namespace, and providing every function with
inline
specifier.