Skip to content

#include <linalg> causes compiler error in VS2022  #266

@QuantDevHacks

Description

@QuantDevHacks

Putting

#include <linalg>

in a source file in Visual Studio 2022, using the VS compiler, results in a compiler error. There is no error when I switch to the LLVM Platform Toolset in my project settings, however.

Details and repro follow:

My VS project name is lin_alg_examples (VS creates a directory of the same name). Under this directory, I created the following subdirectory:

...lin_alg_examples\kokkos\experimental

Under experimental, I placed the mdspan and linalg header files, and the __p0009_bits and __p1673_bits directories:
image

In the project settings, I am using the VS compiler with the latest C++ working draft:
image

I then write an empty main() function:

#include <experimental/mdspan>
#include <experimental/linalg>
#include <vector>#include <cstdlib>
#include <iostream>#include <format>
using std::vector, std::size_t, std::cout, std::format;
namespace stdex = std::experimental;
int main()
{

}

When I build the project, I get the following compiler error messages:

\lin_alg_examples\kokkos\experimental\__p1673_bits\transposed.hpp(255,57): error C2653: 'original_mapping_type': is not a class or namespace name

\lin_alg_examples\kokkos\experimental\__p1673_bits\transposed.hpp(253,17): message : This diagnostic occurred in the compiler generated function 'auto std::experimental::__p1673_version_0::linalg::impl::transposed_layout<std::experimental::layout_stride>::mapping(const std::experimental::layout_stride::mapping<Extents> &)'

It identifies lines 253 and 255 in transposed.hpp; lines 252-255 are as follows:

    template<class OriginalExtents>
    static auto mapping(const typename layout_stride::template mapping<OriginalExtents>& orig_map) {
      using original_mapping_type = typename layout_stride::template mapping<OriginalExtents>;
      using extents_type = transpose_extents_t<typename original_mapping_type::extents_type>;

I tried inserting the "ugly hack" referenced in Issue #242, but this did not fix the problem, even though it seemed it might be related.

If I comment out #include <experimental/linalg>, however, the project builds successfully.

Furthermore, if I restore the file so that the linalg file is included again, and I change the compiler Platform Toolset to the LLVM setting:

image

the code will compile successfully.

One final remark is that the exact same behavior is seen after changing the C++ Language Standard setting to C++20:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions