problem (default argument given for parameter 2 of ..... )

Hello, I have a problem with the sketch, and I'm just a beginner downloaded the sketch from the Internet, maybe an error in the constant.Please help me fix this problem. :frowning:
this is error message

Arduino: 1.8.2 (Windows 10), Плата:"Arduino Uno"

Внимание: platform.txt из ядра 'Arduino AVR Boards' содержит устаревшие recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}", автоматически преобразовано в recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}". Ожидайте обновления ядра.
C:\Users\User\Downloads\source_1_6\source_1_6.ino: In function 'void displayNumber(int, bool)':

source_1_6:385: error: default argument given for parameter 2 of 'void displayNumber(int, bool)' [-fpermissive]

void displayNumber(int number, bool showLeadZeros=false)

^

source_1_6:128: error: after previous specification in 'void displayNumber(int, bool)' [-fpermissive]

void displayNumber(int, bool=false);// Выводит на индикатор цифру

^

C:\Users\User\Downloads\source_1_6\source_1_6.ino: In function 'void setTimer(bool)':

source_1_6:448: error: default argument given for parameter 1 of 'void setTimer(bool)' [-fpermissive]

void setTimer(bool on = true)

^

source_1_6:129: error: after previous specification in 'void setTimer(bool)' [-fpermissive]

void setTimer(bool=true); // Включает (true) или выключает (false) таймер

^

C:\Users\User\Downloads\source_1_6\source_1_6.ino: In function 'void waitForRelease(bool)':

source_1_6:524: error: default argument given for parameter 1 of 'void waitForRelease(bool)' [-fpermissive]

void waitForRelease(bool showTime = true)

^

source_1_6:136: error: after previous specification in 'void waitForRelease(bool)' [-fpermissive]

void waitForRelease(bool=true); // Ожидание отпускания всех кнопок (при этом показывается время)

^

exit status 1
default argument given for parameter 2 of 'void displayNumber(int, bool)' [-fpermissive]

Этот отчёт будет иметь больше информации с
включенной опцией Файл -> Настройки ->
"Показать подробный вывод во время компиляции"

source_1_6.ino (22.9 KB)

Please post the error messages you get in full. The "Copy Error Messages" button just above the error listing will help you.

It compiles o.k. for me with no errors but a load of notes and warnings. What Arduino are you compiling it for?

Steve

You should only specify the default argument in the function prototype. For example, here is the function prototype for your displayNumber function:

void displayNumber(int, bool=false);// Выводит на индикатор цифру

That's fine. Now here is the first line of the definition of your displayNumber function:

void displayNumber(int number, bool showLeadZeros=false)

That's incorrect. It should be:

void displayNumber(int number, bool showLeadZeros)

Do the same for your setTimer and waitForRelease functions.

The reason why you are getting this error and slipstick is not is because you are using some ridiculously outdated version of Arduino AVR Boards. A few years ago, Arduino updated the avr-gcc compiler. This resulted in some things that had previously been warnings to errors. To avoid breaking existing bad, but functional code, Arduino added the -fpermissive flag to the compilation recipes. This had the unfortunate effect of downgrading some things that had previously been errors to warnings. The default argument being defined in both the function prototype and the definition is one of these.

Although it's not absolutely necessary, I very much recommend that you update your Arduino AVR Boards:

  1. Select Tools > Board > Boards Manager from the Arduino IDE menus.
  2. Wait for the updates to finish.
  3. Click on "Arduino AVR Boards".
  4. Click the Update button.
  5. Wait for the update to finish.
  6. Click the Close button.

Not as important, but you might also consider updating your Arduino IDE version. 1.8.2 is pretty old.

1 Like