tomstewart89 / BasicLinearAlgebra

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

works in 3.7 broken in 4.0/4.1 #69

Closed hnnswldschtz closed 8 months ago

hnnswldschtz commented 11 months ago

Hi, really thanks for your work and time on this great Library!

Im working on an ESP32 codebase. Even if there is hardly nothing to compile in main (its the PIO init template, see below), this compiler error happens since 4.0. in 3.7 the compiler went thru. I use VS code with the platform IO plugin.

compiled test code:

#include <Arduino.h>
#include <BasicLinearAlgebra.h>
using namespace BLA;

// put function declarations here:
int myFunction(int, int);

void setup() {
  // put your setup code here, to run once:
  int result = myFunction(2, 3);
}

void loop() {
  // put your main code here, to run repeatedly:
}

// put function definitions here:
int myFunction(int x, int y) {
  return x + y;
}

compiler error in 4.0/4.1:

Compiling .pio/build/featheresp32/FrameworkArduino/WMath.cpp.o
Compiling .pio/build/featheresp32/FrameworkArduino/WString.cpp.o
Compiling .pio/build/featheresp32/FrameworkArduino/base64.cpp.o
Compiling .pio/build/featheresp32/FrameworkArduino/cbuf.cpp.o
In file included from .pio/libdeps/featheresp32/BasicLinearAlgebra/BasicLinearAlgebra.h:158:0,
                 from src/main.cpp:2:
.pio/libdeps/featheresp32/BasicLinearAlgebra/impl/NotSoBasicLinearAlgebra.h: In constructor 'BLA::LUDecomposition<ParentType>::LUDecomposition(BLA::MatrixBase<DerivedType, DerivedType:: Rows, DerivedType:: Cols, typename DerivedType::DType>&)':
.pio/libdeps/featheresp32/BasicLinearAlgebra/impl/NotSoBasicLinearAlgebra.h:25:59: error: expected ',' before ')' token
         static_assert(ParentType::Rows == ParentType::Cols);
                                                           ^
.pio/libdeps/featheresp32/BasicLinearAlgebra/impl/NotSoBasicLinearAlgebra.h:25:59: error: expected string-literal before ')' token

Compiling .pio/build/featheresp32/FrameworkArduino/esp32-hal-adc.c.o
Compiling .pio/build/featheresp32/FrameworkArduino/esp32-hal-bt.c.o
*** [.pio/build/featheresp32/src/main.cpp.o] Error 1
tomstewart89 commented 11 months ago

Hey @hnnswldschtz , thanks for the information!

Looks like the problem is that I didn't give a string message in my static_asserts when I upgraded this library to 4.0. That's legal in C++17 which is the default for the arduino IDE but I guess your compiler is using the C++11 standard.

I'll push some changes to fix that soon but in the meantime if you can configure your project to use a C++17 compiler, then the error message should go away

Hope that helps!

hnnswldschtz commented 11 months ago

Hey @tomstewart89 thanks for your fast reply!

You are totally right. For my PIO setup, I added a string message as a second argument to thestatic_assert() in the NotSoBasicLinearAlgebra.h and everything seems to work fine. Compiling with the arduino IDE works too.

thanks again!

tomstewart89 commented 8 months ago

Sorry for the delay! This should be fixed in v4.3