Unlogical but simple errors coming from P5 to arduino

hello!

I am trying to convert a p5 sketch of mine to arduino.

I got several uncomprehensible errors - see P.S.
I know that’s C++
I assume that all tabs are joined by the pre-compiler, so one global var should be known to all.
I also understand white space doesn’t matter.
I find that the line numbers from the error don’t apply when you have empty lines or comments.

How can I tackle my errors?

This is the start

#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#define intConstEnde 7 ; // 0..10, also 11 Felder breit und hoch: hier 10 eintragen
Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();


const int statePlay = 1; // solving the game that has beeen chosen
int state;
const int configurationFirePlaceBoard = 0;
const int configurationCrossBoard     = 1;
const int configurationEnglishBoard   = 2;  
int currentConfiguration;
boolean programEnd;
boolean boolFindAllSolutions; 
int textXPos;
boolean itIsFirstTime;
const String strConstTitel;
const int constSpielfeldLeer = 2;            // Feld leer
const int constSpielfeldBesetzt = 1;         // Feld besetzt
const int constSpielfeldNichtVorhanden = 0;  // Eckfelder werden nicht bespielt
const int  constNorden = 0;    // Auf einer Ebene
const int  constOsten = 1;
const int  constSueden = 2;
const int  constWesten = 3;
const int  constNordost = 6;      //  Diagonal in 2D;
const int  constSuedost = 7;      //  Diagonal in 2D;
const int  constSuedwest = 8;     //  Diagonal in 2D;
const int  constNordwest = 9;     //  Diagonal in 2D;
//
int intMaxRichtung;

// Spielfeld                             x               y          
int SpielfeldGlobal[intConstEnde][intConstEnde];    // array

// Others
long intEndstellungenCounter;
long NumberSolutions;
String constZielStellung;
String solutions;
boolean boolOnlyHorizontalAndVerticalMovesRequired;
String strLogCurrentSolution; 
String strLogOldSolution; 

String input = "0123";

// =============================================================

void setup () {
  //size (1230, 800);
  //  textXPos = width/2-300;
  //  rectFireplaceBoard = new Rectangle(textXPos, textYPos[0], 500, 145, "", "Solve Fireplace Board (medium)");
  //  rectCrossBoard     = new Rectangle(textXPos, textYPos[1], 500, 145, "", "Solve Cross (easy)");
  //  rectEnglishBoard   = new Rectangle(textXPos, textYPos[2], 500, 145, "", "Solve English Board (hard)");  
  //  rectLearnmore      = new Rectangle(textXPos+400, textYPos[3], 100, 25, "Learn more", 
  //  "Learn more about the Game Solitaire." );  

  state = statePlay; 
  currentConfiguration = configurationEnglishBoard

    Serial.begin(9600);
  Serial.println("8x8 LED Matrix Test");

  matrix.begin(0x70);  // pass in the address
}

Thanks a lot!

xx

P.S.

SolitaireSolver7:13: error: expected ]' before ';' token SolitaireSolver7:13: error: expected )’ before ‘;’ token
SolitaireSolver7:13: error: expected unqualified-id before ‘]’ token
SolitaireSolver7:13: error: expected unqualified-id before ‘]’ token
SolitaireSolver7:15: error: expected unqualified-id before ‘[’ token
SolitaireSolver7:22: error: expected unqualified-id before ‘[’ token
SolitaireSolver7:29: error: expected unqualified-id before ‘[’ token
SolitaireSolver7:34: error: expected ]' before ';' token SolitaireSolver7:34: error: expected unqualified-id before ']' token SolitaireSolver7:34: error: expected unqualified-id before ']' token SolitaireSolver7.ino: In function 'void setup()': SolitaireSolver7:61: error: expected ;’ before ‘Serial’
Game1.ino: In function ‘void SolveGame()’:
Game1:35: error: ‘SpielfeldGlobal’ was not declared in this scope
Game1:38: error: ‘SpielRekursiv’ was not declared in this scope
Game1.ino: In function ‘void DefiniereStartUndZielstellung()’:
Game1:76: error: ‘SpielfeldGlobal’ was not declared in this scope
Game2.ino: At global scope:
Game2:7: error: expected ]' before ';' token Game2:7: error: expected )’ before ‘;’ token
Game2:7: error: expected constructor, destructor, or type conversion before ‘;’ token
Game2:7: error: expected unqualified-id before ‘]’ token
Game2:7: error: expected unqualified-id before ‘]’ token

Posting your code would help. Run the auto formatter (on the tool bar) and you will SEE your errors.

Mark

hello and thank you!

I posted the error messages and the part of the code that is causing most errors (imho)

I couldn't post th whole code since it's far too long and distributed over a lot of tabs.

Couldn't you take a look at the code I posted please?

Anyway, ctrl-t I use all the time, but it didn't give me errors.

I get those only when I Compile.

Also you said tool bar - isn't that a tool menu? Or am I using an old version of the PDE?

Thank you,

see you!

Ronwl

Let's start with a simple one. #define intConstEnde 7 ; // 0..10, also 11 Felder breit und hoch: hier 10 eintragenWhat will intConstEnde be replaced with in the code when this #define is executed ?

err... with 7 (after the // only comment)

i was porting this code from processing / java to C++ without knowing C++

So I had to replace final int with #define...

Am I wrong with 7 ? I did google that - or tried to...

oh, no ; allowed here!!!

It's allowed if you really needed it, but you don't.

Next observation

  currentConfiguration = configurationEnglishBoard

Perhaps you could use the spare semi-colon from the #define

thanks

is that ok:

const int constSpielfeldLeer = 2;            // Feld leer

sorry, how can I let a function return a 2D arrays please?

int[][] arrayCopy2D ( int src [7][7])  
{
......................
}

Is that ok?

const int constSpielfeldLeer = 2;            // Feld leerYes, that is valid code

int[][] arrayCopy2D ( int src [7][7])That isn’t. Why not make the array global ?

thanks...

No, making my array global is not an option since I use a recursive function where every function call delivers a new local array

Best, Chrisir

define intConstEnde 7 ;

define does not end with a semicolon.

yes, well spotted!

these are the current errors I get

SolitaireSolver7:16: error: expected unqualified-id before '[' token
SolitaireSolver7:23: error: expected unqualified-id before '[' token
SolitaireSolver7:30: error: expected unqualified-id before '[' token
Game2.ino: In function 'void SpielRekursiv(int (*)[7], int, String)':
Game2:50: error: 'arrayCopy2D' was not declared in this scope
Game2:52: error: 'ZugAusfuehren' was not declared in this scope
Game2.ino: In function 'void outArduino(int (*)[7])':
Game2:83: error: 'Spielfeld' was not declared in this scope
Game2.ino: In function 'int PrintFunktionForArduino(int)':
Game2:98: error: invalid conversion from 'const char*' to 'int'
Game3.ino: At global scope:
Game3:110: error: expected unqualified-id before '[' token

sorry, how can I let a function return a 2D arrays please?

Code:

int[][] arrayCopy2D ( int src [7][7]) { ...................... }

Is that ok?

In java it is.

I would really recommend giving some brief consideration to the syntactical difference between java and c/c++

Spending 15 minutes reading this:

https://en.wikipedia.org/wiki/Comparison_of_Java_and_C%2B%2B

Would probably be time well invested, and plenty of links to more details.

olitaireSolver7:16: error: expected unqualified-id before '[' token

Well, what is the code on line 16 of that file ? I am not psychic.

thank you…

this is the start of my sketch (line 16 therein, but the line numbers don’t really match imho)

#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#define intConstEnde 7 
Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();
const int statePlay = 1; // solving the game that has beeen chosen
int state = 1;
const int configurationFirePlaceBoard = 0;
const int configurationCrossBoard     = 1;
const int configurationEnglishBoard   = 2;  
int currentConfiguration = 2;
boolean programEnd = false;
boolean boolFindAllSolutions = false; 
int textXPos = 0;
boolean itIsFirstTime = false;
const String strConstTitel = "";
const int constSpielfeldLeer = 2;            // Feld leer
const int constSpielfeldBesetzt = 1;         // Feld besetzt
const int constSpielfeldNichtVorhanden = 0;  // Eckfelder werden nicht bespielt
const int constNorden = 0;    // Auf einer Ebene
const int constOsten = 1;
const int constSueden = 2;
const int constWesten = 3;
int intMaxRichtung;
int SpielfeldGlobal[7][7];    // array
long intEndstellungenCounter;
long NumberSolutions;
String constZielStellung;
String solutions;
boolean boolOnlyHorizontalAndVerticalMovesRequired;
String strLogCurrentSolution; 
String strLogOldSolution; 

String input = "0123";

// =============================================================

void setup () {

Sorry, I found out that the error in the code is totally somewhere else as where the error message said, so the lines I posted won't help.

I'm on it.

Ronwl:
Sorry, I found out that the error in the code is totally somewhere else as where the error message said, so the lines I posted won’t help.

Which is why it is always best to post or attach a whole program that exhibits the problem.