Unterminated argument list invoking macro "round" error

Hello!

I am having this error in the Arduino IDE 1.8.19:

NeoPixel_Hue_Rotater:559:0: error: unterminated argument list invoking macro "round"
exit status 1
unterminated argument list invoking macro "round"

I'm using an Arduino Uno with macOS Monterey.
The error happens on line 559:

digitalWrite(buzzGndPin, LOW);

but when I delete the line, the error occurs at the line above.

Full Code: NeoPixel_Hue_Rotater.ino (13.1 KB)
Full error message (copy error messages): Error_Messages.txt (339 Bytes)

Thank you! :slightly_smiling_face:
tinkerer9

Maybe something was changed from a macro to a function or the other way around. The round() macro is a serious problem: https://github.com/arduino/ArduinoCore-API/issues/76
The "round()" function is a standard 'C' function for floating point. Arduino has thrown the standard away in my opinion. The standard is sacred, I think that Arduino has made a very big mistake.

It is with a Arduino Uno ? Then here is the very bad round() macro and here is the map().

Every round() in your file is after calling the map() function. The round() does nothing, because the map() function already return a whole number, because it returns a 'long'. You can remove all those round() calls.

1 Like

Thank you! It worked!
Yes, I was using an Arduino Uno.
Although your solution doesn't explain the error (update: post #4 did), I am not using round(); anymore so it doesn't matter.

New Code: NeoPixel_Hue_Rotater.ino (13.1 KB)

tinkerer9

This is the macro:

#define round(x)  ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

As long as "x" is a number or a variable, then it is okay.
But if "x" is a function, then that function gets called multiple times and that function should be called just once. The function itself has also arguments.
The compiler tries to do the macro, but it gets tangled up. [EDIT] No, it was a mismatch of brackets as oqibidipo writes below here.
I think the compiler could just say: "NeoPixel_Hue_Rotater:559:0: error: This is nuts".

Macro's can be dangerous. A function is often better but a function has fixed variable types for the parameters. In C++ there is a flexible "template" which is not dangerous.

1 Like

Here is was your problem:

int time_left_to_pixel(int milli, int milli_left) {
  int pixels =  round(map(milli_left, 0, milli, 1, (neoLeds - 1));      
                     (   (                         (           ))
1 Like

I'm not sure...
Though it was also a problem, the compiler didn't tell that error.

So even if I had to use round() it would be better to use:

int out = map(in, inMin, inMax, outMin, outMax);
out = round(out);
return out;

in a function?

Also,

how are macro's dangerous (just out of curiosity)?

tinkerer9

In a function with more code lines it will work.

The round() macro assumes that its parameter is a number or a variable. But then it is used in a different way. Luckily the compiler gave an error message. If the compiler would accept a wrong-used macro, then someone would spend a lot of time to find the bug.
A typical dangerous scenario is calling a macro from another macro.
Also, a "#define" can be undefined or redefined anywhere in the code and the compiler accepts it. So also a macro can be changed. That's just nasty.

Thank you oqibidipo :heart: I totally missed that. I got triggered by the round() macro and didn't look further, that is a typical beginner's mistake on my side.

I also ended up finding that fluke before testing @Koepel's solution, and both were the problem. Thanks, @Koepel and @oqibidipo.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.