Anonymous namespace causing warning
Closed this issue · 5 comments
I'm getting the following warning (or error in this case, as I have warnings as errors enabled) while compiling pffft with GCC on ARM64, with strict warnings enabled:
[build] /home/pi/convolution-thing/source/../externals/pffft/pffft.hpp: In instantiation of ‘class pffft::Fft<float>’:
[build] /home/pi/convolution-thing/source/./math/FFTpffft.h:25:20: required from here
[build] /home/pi/convolution-thing/source/../externals/pffft/pffft.hpp:124:7: error: ‘pffft::Fft<float>’ has a field ‘pffft::Fft<float>::setup’ whose type uses the anonymous namespace [-Werror=subobject-linkage]
I looked into the issue and looks like the problem is that each source file including the header will get its own copy of the anonymous namespace, which means the type will have a different definition in different compile units. I was unable to fix the issue myself as I don't have a good grasp of the structure of pffft, so can't attach a pull request either.
Here's some discussion on the issue:
https://stackoverflow.com/questions/37722850/how-to-silence-whose-type-uses-the-anonymous-namespace-werror-gcc-version-4
hey @ilmai, that makes sense. i'll take a look at it. probably the best fix is to change the anonymous namespace into namespace detail
.
@ilmai, maybe this https://github.com/unevens/pffft/tree/detail fixes it for you?
Unfortunately that fix surfaces another anonymous namespace error, and I'm not actually sure what it's complaining about here as PFFFT_Setup is not within a namespace:
[build] /home/pi/convolution-thing/source/../externals/pffft/pffft.hpp:427:7: error: ‘pffft::detail::Setup<float>’ has a field ‘pffft::detail::Setup<float>::self’ whose type uses the anonymous namespace [-Werror=subobject-linkage]
[build] class Setup<float>
it's because the include directives for the c headers are in the anonymous namespace, and hence the whole c headers are. i didn't think it was a problem becuase PFFFT_Setup it's just declared there, not defined. anyway, i moved them also in the detail namespace now, unevens@5991c2f
Thank you, that fixed the issue!