4

I have a templated class in a module file and when exporting the module it works fine, however when importaing I get a COMDAT exception. Are there specific constraints on how to export templated classes out of modules. I saw this post, however it seems not to solve the COMDAT exception I receive. My code has the following Layout:

export namespace Foo {
    template <typename T>
    class Bar {
      ...
    }
}

However, when I link it with my GoogleTest Project and compile that one I receive a:

LNK1179 invalid or corrupt file: duplicate COMDAT '??$_Allocate_manually_vector_aligned@U_Default_allocate_traits@std@@@std@@YAPEAX_K@Z' ...

Finally, I tried a template class<std::string> at the end of the namespace but that seems

  1. Not working first off, still same exception
  2. Not expandable if I have to modify my .ixx for everything

Lastly, I'm using C++ 20 with MSVC v143 compiling to a static library. Is there anything I'm missing?

Alex
  • 439
  • 5
  • 16
  • 2
    It seems there are still some bugs related to modules in current version of MSVC. https://developercommunity.visualstudio.com/t/lnk1179-invalid-or-corrupt-file-duplicate-comdat-f/1517475 https://developercommunity.visualstudio.com/t/VS-16104-:-fatal-error-LNK1179:-invali/1497163 https://stackoverflow.com/questions/72288809/error-lnk1179-invalid-or-corrupt-file-duplicate-comdat-when-trying-to-build-as – zigzag May 26 '22 at 07:26
  • That's a pity, thanks for the info though – Alex May 26 '22 at 18:31

0 Answers0