tomstewart89 / BasicLinearAlgebra

A library for using matrices and linear algebra on Arduino
MIT License
187 stars 38 forks source link

examples don't compile #31

Closed zachary-koumi closed 3 years ago

zachary-koumi commented 3 years ago

When i try to compile the example 'HowToUse.ino' using the arduino ide i get a whole bunch of errors.

In file included from /home/zac/sketchbook/libraries/basiclinearalgebra/BasicLinearAlgebra.h:9:0, from HowToUse.ino:1: /home/zac/sketchbook/libraries/basiclinearalgebra/MemoryDelegate.hpp:64:55: error: expected unqualified-id before ‘using’ template<int rows, int cols = 1, class ElemT = float> using ArrayMatrix = Matrix<rows,cols,Array<rows,cols,ElemT> >; ^ /home/zac/sketchbook/libraries/basiclinearalgebra/MemoryDelegate.hpp:84:51: error: expected unqualified-id before ‘using’ template<int rows, int cols, class ElemT = float> using ArrayRef = Reference<Array<rows,cols,ElemT> >; ^ /home/zac/sketchbook/libraries/basiclinearalgebra/MemoryDelegate.hpp:85:49: error: expected unqualified-id before ‘using’ template<int rows, int cols, class ParentMemT > using RefMatrix = Matrix<rows,cols,Reference >; ^ /home/zac/sketchbook/libraries/basiclinearalgebra/MemoryDelegate.hpp:105:58: error: expected unqualified-id before ‘using’ template<int rows, int cols = rows, class ElemT = float> using Identity = Matrix<rows,cols,Iden >; ^ /home/zac/sketchbook/libraries/basiclinearalgebra/MemoryDelegate.hpp:121:55: error: expected unqualified-id before ‘using’ template<int rows, int cols = 1, class ElemT = float> using Zeros = Matrix<rows,cols,Zero >; ^ /home/zac/sketchbook/libraries/basiclinearalgebra/MemoryDelegate.hpp:183:73: error: expected unqualified-id before ‘using’ template<int rows, int cols, int tableSize = cols, class ElemT = float> using SparseMatrix = Matrix<rows,cols,Sparse<cols,tableSize,ElemT> >; ^ In file included from HowToUse.ino:1:0: /home/zac/sketchbook/libraries/basiclinearalgebra/BasicLinearAlgebra.h: In member function ‘void BLA::Matrix<rows, cols, MemT>::FillRowMajor(typename MemT::elem_t, TAIL ...)’: /home/zac/sketchbook/libraries/basiclinearalgebra/BasicLinearAlgebra.h:206:91: error: there are no arguments to ‘static_assert’ that depend on a template parameter, so a declaration of ‘static_assert’ must be available [-fpermissive] static_assert(rowscols > sizeof...(TAIL), "Too many arguments passed to FillRowMajor"); ^ /home/zac/sketchbook/libraries/basiclinearalgebra/BasicLinearAlgebra.h:206:91: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated) HowToUse.ino: In function ‘void setup()’: HowToUse.ino:42:36: error: in C++98 ‘B’ must be initialised by constructor, not by ‘{...}’ HowToUse.ino:86:8: error: ‘refAonTopOfB’ does not name a type In file included from HowToUse.ino:1:0: /home/zac/sketchbook/libraries/basiclinearalgebra/BasicLinearAlgebra.h: In instantiation of ‘void BLA::Matrix<rows, cols, MemT>::FillRowMajor(typename MemT::elem_t, TAIL ...) [with TAIL = {double, double, double, double, double, double, double, double}; int rows = 3; int cols = 3; MemT = BLA::Array<3, 3, float>; typename MemT::elem_t = float]’: /home/zac/sketchbook/libraries/basiclinearalgebra/BasicLinearAlgebra.h:58:67: required from ‘BLA::Matrix<rows, cols, MemT>::Matrix(ARGS ...) [with ARGS = {double, double, double, double, double, double, double, double, double}; int rows = 3; int cols = 3; MemT = BLA::Array<3, 3, float>]’ HowToUse.ino:42:36: required from here /home/zac/sketchbook/libraries/basiclinearalgebra/BasicLinearAlgebra.h:206:18: error: ‘static_assert’ was not declared in this scope static_assert(rowscols > sizeof...(TAIL), "Too many arguments passed to FillRowMajor"); ^

thomascent commented 3 years ago

Hey @zachary-koumi,

I'm pretty sure the problem is that you've set your compiler to C++98 as indicated by this line in your compiler output:

HowToUse.ino:42:36: error: in C++98 ‘B’ must be initialised by constructor, not by ‘{...}’

This library relies on features from C++11 so you'll need to change that setting in your IDE. I've never had occasion to do that but by the looks of it you can find some information on how to do that here: https://forum.arduino.cc/t/changing-finding-out-the-c-compiler-version/604413

zachary-koumi commented 3 years ago

Thanks for your help. The easiest way to solve the problem was just to download the arduino ide from the arduino website instead of using the one on the ubuntu repository.