Skip to content

Compile Error: redeclaration of template feng::matrix_view #7

@Zachary-Harrison

Description

@Zachary-Harrison

System information/specifications:

  • OS: Windows 11
  • GNU Make 4.4.1
  • g++.exe (Rev8, Built by MSYS2 project) 15.2.0

Using the provided source code, I receive the following errors:

$ make test
g++ -c -std=c++20 -Wall -Wextra -fmax-errors=1 -Ofast -flto=auto  -funroll-all-loops -pipe -march=native -DPARALLEL  -o ./test.o tests/test.cc
In file included from tests/test.cc:1:
tests/../matrix.hpp:4052:173: error: redeclaration of 'template<class Type, class Alloc>  requires  Allocator<Alloc> struct feng::matrix_view' with different constraints [-Wtemplate-body]
 4052 |     matrix_view<Type, Alloc>::matrix_view( matrix<Type, Alloc> const& mat, std::pair<size_type, size_type> const& row_dim, std::pair<size_type, size_type> const& col_dim ) noexcept: matrix_{ mat }
      |                                                                                                                                                                             ^~~~~~~~
compilation terminated due to -fmax-errors=1.
make: *** [Makefile:26: test] Error 1

$ make example
g++ -c -std=c++20 -Wall -Wextra -fmax-errors=1 -Ofast -flto=auto  -funroll-all-loops -pipe -march=native -DPARALLEL  -o ./example.o examples/example.cc
In file included from examples/example.cc:3:
examples/../matrix.hpp:4052:173: error: redeclaration of 'template<class Type, class Alloc>  requires  Allocator<Alloc> struct feng::matrix_view' with different constraints [-Wtemplate-body]
 4052 |     matrix_view<Type, Alloc>::matrix_view( matrix<Type, Alloc> const& mat, std::pair<size_type, size_type> const& row_dim, std::pair<size_type, size_type> const& col_dim ) noexcept: matrix_{ mat }
      |                                                                                                                                                                             ^~~~~~~~
compilation terminated due to -fmax-errors=1.

Please note that I am able to get programs to compile using matrix.hpp, so long as they do not use any of the important functions (i.e. .save_as_bmp(), lu_solver(), svd(), etc...). For instance, the following alteration of the provided main.cpp file will compile and run just fine:

#include "matrix.hpp"
int main()
{
    feng::matrix<double> m{ 64, 256 };
    int starter = 0;
    double const keys[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
    for (auto& x : m)
    {
        int val = starter++ & 0x7;
        x = keys[val];
    }
    // m.save_as_bmp("./images/0000_access.bmp");
    return 0;
}

Unfortunately, this greatly hinders the usefulness of matrix.hpp. Any ideas for fixes? I'm unsure if this is a problem constrained to my machine or if others are experiencing something similar using my system specifications.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions