Hello,
my area of competence is more hardware-oriented, but I really like it and I've learned a lot about software.
I study C on websites such as learncpp.com, but I feel I lack some foundation or deeper understanding.
I like to help here on the forum because I learn more than I help, and I still hear a lot of positive reviews in my helps.
I'm currently trying to help a user, but I'm having a hard time understanding the various errors in a library.
The topic I'm trying to help is this:
" Nodemcu, library compilation error - #5 by GorkemKolsun "
I downloaded the library and found that a code with it actually compiles correctly with Arduino Mega but does not compile with ESP8266-12E.
Looking to understand the causes of failures and focused on the first error.
I reduced the code and the library to the minimum that still causes an error.
error msgs:
Arduino: 1.8.9 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"
C:\Users\ruilv\Documents\Arduino\libraries\ArduinoMatrixLibrary-master\MatrixLibrary.cpp:33:61: error: default argument given for parameter 3 of 'Matrix::Matrix(int, int, double)' [-fpermissive]
Matrix::Matrix(int rows, int cols, double initialValue = 0.0)
^
In file included from C:\Users\ruilv\Documents\Arduino\libraries\ArduinoMatrixLibrary-master\MatrixLibrary.cpp:27:0:
C:\Users\ruilv\Documents\Arduino\libraries\ArduinoMatrixLibrary-master/MatrixLibrary.h:34:2: error: after previous specification in 'Matrix::Matrix(int, int, double)' [-fpermissive]
Matrix(int rows, int cols, double initialValue = 0.0);
^
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Here is the code:
#include <MatrixLibrary.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
}
Here MatrixLibrary.cpp:
/*
MatrixLibrary.cpp - Class file for the Matrix Algebra Library for Arduino.
Version: 1.0.0
(c) 2018 Thomas Bartleet
www.github.com/TheForeignMan
This program is free software: you can redistribute it and/or modify
it under the terms of the version 3 GNU General Public License as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <MatrixLibrary.h>
///////////////////
// CONSTRUCTORS
// Creates a new matrix of size rows x cols. Default contents are 0.0
Matrix::Matrix(int rows, int cols, double initialValue = 0.0)
{
*thisMatrix = 20;
}
And here MatrixLibrary.h
/*
MatrixLibrary.h - Header file for the Matrix Algebra Library for Arduino.
Version: 1.0.0
(c) 2018 Thomas Bartleet
www.github.com/TheForeignMan
This program is free software: you can redistribute it and/or modify
it under the terms of the version 3 GNU General Public License as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MatrixLibrary_h
#define MatrixLibrary_h
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
class Matrix
{
public:
Matrix(int rows, int cols, double initialValue = 0.0);
private:
double *thisMatrix;
};
#endif
As it is, it compiles correctly with Arduino Mega, but it gives a compilation error with ESP8266.
If I change these lines:
MatrixLibrary.h
Matrix(int rows, int cols, double initialValue = 0.0);
to
Matrix(int rows, int cols, double initialValue);
and
MatrixLibrary.cpp
Matrix::Matrix(int rows, int cols, double initialValue = 0.0)
to
Matrix::Matrix(int rows, int cols, double initialValue)
thisMatrix = 20;
to
*thisMatrix = 20;
compiles without error.
Why, using no change, compile correctly for Arduino Mega and not compile for ESP8266?
With your help I will learn a little more.
Thanks in advance