Compiler errors in PIO but not in Arduino IDE error: too many arguments

Hi,

I tried to compile the following code on Visual Studio Code with the PIO extension for an Arduino UNO R4 WiFi:

#include <Arduino.h>
#include <SoftwareSerial.h>

#define rx_Pin 10
#define tx_Pin 11
#define DE_Pin 3
#define RE_Pin 4
#define LED 13

SoftwareSerial RS485_Serial =  SoftwareSerial(rx_Pin, tx_Pin);

const char compile_date[] = __DATE__ " " __TIME__;  // Built Information

// declare functions
void serialHandler();
void statemachine_RS485_com();
void serialEvent();
void _debug();

// Definition f states
enum comstates{
  com_standby,
  com_send,
  com_receive,
  com_timeout = 90
};

// input string
String input_string = "h";
bool input_serialHandler = true;

// init states
uint8_t com_state = com_standby;
uint32_t com_state_timer = 0;

// com_states variables


void setup() {
  pinMode(rx_Pin, INPUT);
  pinMode(tx_Pin, OUTPUT);
  pinMode(DE_Pin, OUTPUT);
  pinMode(RE_Pin, OUTPUT);

  digitalWrite(DE_Pin, HIGH);
  digitalWrite(RE_Pin, HIGH);

  Serial.begin(115200);
  RS485_Serial.begin(19200);
  __debug(F("RS485_statemachine_R4"));
  __debug("built: " + (String)compile_date);
  __debug("");
}

void loop() {
  if (input_serialHandler) {
    serialHandler();
    input_string="";
    input_serialHandler = false;
  }
  statemachine_RS485_com();
}

void serialHandler() {
  switch (input_string.charAt(0)) {

  case 'h':
    _debug(F("######################"));
    _debug(F("RS485_statemachine_R4"));
    _debug("built: " + (String)compile_date);
    _debug(F("######################"));
    _debug(F("h - display this help"));
    break;

  case 'i':
    break;

  default:
    _debug("serialHandler|unknown command|" + input_string);
    break;
  }
}

void statemachine_RS485_com () {
  switch (com_state) {

  case com_standby:
    /* code */
    break;
  
  default:
    break;
  }
}

void serialEvent() {
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    if (inChar == 10) {
      input_serialHandler = true;
    }
    else if (isAlphaNumeric(inChar)) {
      input_string += inChar;
    }
  }
}

String _convert_unsigned_long_to_String(unsigned long input, int ziellaenge) {
  String converttemp = (String)input;
  while (converttemp.length() < ziellaenge) {
    converttemp = " " + converttemp;
  }
  return converttemp;
}

void _debug(String _debugtext) { // _debuging
  Serial.println(_convert_unsigned_long_to_String(millis(), 6) + "|" + _debugtext);
}

The code compiles fine on the Arduino IDE but on PIO I get the following errors:

rc/main.cpp: In function 'void serialHandler()':
src/main.cpp:75:39: error: too many arguments to function 'void _debug()'
     _debug(F("######################"));
                                       ^
src/main.cpp:25:6: note: declared here
 void _debug();
      ^~~~~~
src/main.cpp:76:38: error: too many arguments to function 'void _debug()'
     _debug(F("RS485_statemachine_R4"));
                                      ^
src/main.cpp:25:6: note: declared here
 void _debug();
      ^~~~~~
src/main.cpp:77:44: error: too many arguments to function 'void _debug()'
     _debug("built: " + (String)compile_date);
                                            ^
src/main.cpp:25:6: note: declared here
 void _debug();
      ^~~~~~
src/main.cpp:78:39: error: too many arguments to function 'void _debug()'
     _debug(F("######################"));
                                       ^
src/main.cpp:25:6: note: declared here
 void _debug();
      ^~~~~~
src/main.cpp:79:38: error: too many arguments to function 'void _debug()'
     _debug(F("h - display this help"));
                                      ^
src/main.cpp:25:6: note: declared here
 void _debug();
      ^~~~~~
src/main.cpp:86:59: error: too many arguments to function 'void _debug()'
     _debug("serialHandler|unknown command|" + input_string);
                                                           ^
src/main.cpp:25:6: note: declared here
 void _debug();

What am i doing wrong?

The definition

does not match the predeclaration:

The correct predeclaration will do the trick:

void _debug(String _debugtext);
1 Like