Strange error occurs without changing the code.

Hello,

Today I wanted to upload some edits to my program that is running on my arduino board but the compiler gives me a error i cannot resolve:

SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:-1: error: expected ',' or '...' before numeric constant
SchrijfRobot:0: error: expected ',' or '...' before numeric constant
SchrijfRobot:1: error: expected ',' or '...' before numeric constant
SchrijfRobot:2: error: expected ',' or '...' before numeric constant
SchrijfRobot:3: error: expected ',' or '...' before numeric constant
SchrijfRobot:4: error: expected ',' or '...' before numeric constant
SchrijfRobot:5: error: expected ',' or '...' before numeric constant
SchrijfRobot:6: error: expected ',' or '...' before numeric constant
SchrijfRobot:7: error: expected ',' or '...' before numeric constant
SchrijfRobot:8: error: expected ',' or '...' before numeric constant
LetterFunctions:8: error: expected ',' or '...' before numeric constant
LetterFunctions:14: error: expected ',' or '...' before numeric constant
LetterFunctions:31: error: expected ',' or '...' before numeric constant
LetterFunctions:58: error: expected ',' or '...' before numeric constant
LetterFunctions:83: error: expected ',' or '...' before numeric constant
LetterFunctions:101: error: expected ',' or '...' before numeric constant
LetterFunctions:122: error: expected ',' or '...' before numeric constant
LetterFunctions:139: error: expected ',' or '...' before numeric constant
LetterFunctions:176: error: expected ',' or '...' before numeric constant
LetterFunctions:189: error: expected ',' or '...' before numeric constant
LetterFunctions:207: error: expected ',' or '...' before numeric constant
LetterFunctions:228: error: expected ',' or '...' before numeric constant
LetterFunctions:244: error: expected ',' or '...' before numeric constant
LetterFunctions:256: error: expected ',' or '...' before numeric constant
LetterFunctions:269: error: expected ',' or '...' before numeric constant
LetterFunctions:281: error: expected ',' or '...' before numeric constant
LetterFunctions:304: error: expected ',' or '...' before numeric constant
LetterFunctions:324: error: expected ',' or '...' before numeric constant
LetterFunctions:353: error: expected ',' or '...' before numeric constant
LetterFunctions:373: error: expected ',' or '...' before numeric constant
LetterFunctions:415: error: expected ',' or '...' before numeric constant
LetterFunctions:428: error: expected ',' or '...' before numeric constant
LetterFunctions:453: error: expected ',' or '...' before numeric constant
LetterFunctions:466: error: expected ',' or '...' before numeric constant
LetterFunctions:483: error: expected ',' or '...' before numeric constant
LetterFunctions:496: error: expected ',' or '...' before numeric constant
LetterFunctions:511: error: expected ',' or '...' before numeric constant

I have the script stored on dropbox so I inmidiately restored it to the last script I knew I uploaded but I get exactly the same problem.
here is a snippet of my code:

#include <EEPROM.h>                // Needed to write to EEPROM memory

#define STANDARD_STEP_DELAY 800    // The delay for each step (in microseconds) determence the speed of the motors
#define START_OFFSET 30            // How many steps the robot makes forward before it starts writing
#define STANDARD_LETTER_OFFSET 30  // Standard offset make some space between 2 letters.
#define BUTTON 8
#define Scale 10                   // Standard scale for each letter, Letters who are to big or to small get a custom scale

boolean FirstLetter=true;
char EEPROMWordArray[50];          // The word can contain max 50 characters

void setup() {
  for(int i=2;i<=5;i++){
    pinMode(i, OUTPUT);                     // set pin 2 till 5 to output
  }
  pinMode(BUTTON,INPUT);                    // set button pin to input
  Serial.begin(9600);                       // begin serial communication
  Serial.println("Type a word to write, all lowercase letters");
  Serial.print("The current word is: ");
  
  for(int i=0;i<50;i++){                    // loop trought te max 50 characters of the word that needs to be written
    EEPROMWordArray[i]=EEPROM.read(i);      // read stored char array
    Serial.write(EEPROMWordArray[i]);       // write currently stored word to serial monitor
  }
  
  Serial.println();                         // new line
}



void loop()
{          
  checkSerialInput();                // Checks if the user wants to put in a new word.
  if(digitalRead(BUTTON)){           // If the butten is pressed the program will start writing the currently stored word
    delay(1000);
    Write();                         // Function that loops the WordArray in a switch wich calls the correct letterFunctions
    delay(5000);
  }
}

For what its worth, I tried moving around with the #define variables and I clicked on Fix encoding & Reload for a couple of times with no result...

EDIT: I counted the line numbers of the errors in my LetterFunctions file and the line numbers are on each new void i make.

If I write dummy functions for, or comment out

  checkSerialInput();                // Checks if the user wants to put in a new word.

and

    Write();                         // Function that loops the WordArray in a switch wich calls the correct letterFunctions

as you didn't post them, it compiles fine.

jaapbaardaap:
EDIT: I counted the line numbers of the errors in my LetterFunctions file and the line numbers are on each new void i make.

I actually got:

sketch_mar16b.cpp: In function 'void loop()':
sketch_mar16b:32: error: 'checkSerialInput' was not declared in this scope
sketch_mar16b:35: error: 'Write' was not declared in this scope

... on each new void i make

What's a void?

No the functions work correct. I've found the problem just now. I looked on google and some people had this issue if they would define some variable names that are not distinctive enough like

#define a 4

now I commented out my define variables one by one till the error went away, this was the cause:

#define Scale 10                   // Standard scale for each letter, Letters who are to big or to small get a custom scale

I still dont know why it doesn't compile today and has compiled for a couple of days since I use define but it works now :slight_smile:

To make things clear, the snippet I posted does not contain all my functions. It would be to big to put all of it in this post and since it had worked for days I was sure the problem wasn't in those functions. (I also commented them out myself and got the same error)

with a new void i mean a new function like this one:

void checkSerialInput(){                   //This function reads serial input from the user and stores it in the EEPROM memory.
  if(Serial.available()>0){                //Check if new serial data is available
    char WordArray[50];                    //The word can contain max 50 characters
    for(int i=0;i<50;i++){
      WordArray[i]=0;
    }
    delay(5);                             //Wait for all characters to be send before reading them.
    int i=0;                               //Counter to fill the WordArray
    
    while(Serial.available()){ 
      WordArray[i]=Serial.read();                      //Read Serial input character by character and put them in the word array
      i++;
    }
    
    Serial.print("Word to be written is set to: ");
    
    for(i=0;i<50;i++){
      EEPROM.write(i,WordArray[i]);        //Writes the WordArray to EEPROM memory
      Serial.write(WordArray[i]);          //Writes the WordArray to Serial monitor
      EEPROMWordArray[i]=WordArray[i];     //Puts the WordArray into EEPROMWordArray so it doesnt have to be read again.
    }
    
    Serial.println();
  }  
}

But the topic can be closed since I've found the solution :slight_smile:

jaapbaardaap:
... some people had this issue if they would define some variable names that are not distinctive enough like

#define a 4

now I commented out my define variables one by one till the error went away, this was the cause:

#define Scale 10                   // Standard scale for each letter, Letters who are to big or to small get a custom scale

Just as a tip for the future, if you change that to:

const int Scale = 10;

Then you get less confusing errors. The compiler might say for example "Scale already defined". But when you use a #define it does straight text substitution (eg. "find Scale, replace by 10") which can cause strange errors.