I've declared a variable called "seconds" ...

... and it shows in my sketch as red text, indicating it is a reserved name.

I can't find any reference to this in the online reference ...

So, is it not usable ? The sketch seems to compile and work admirably, so why the red highlighting ?

Sorry, I can't include the sketch for contractual reasons....

Thoughts and prayers.

seconds is not a reserved word.

“Sorry, I can't include the sketch for contractual reasons....“

Sorry, we cannot help you then.


Okay maybe we can.

What happens when you compile the sketch ?

If you don’t like RED put a capital S on seconds.

larryd:
“Sorry, I can’t include the sketch for contractual reasons…“

Sorry, we cannot help you then.

If I don’t own the copyright, I cannot post, but I thought the questions was genuine.

larryd:

Okay maybe we can.

What happens when you compile the sketch ?

?


And in my first post I said the sketch compiles and runs fine…

larryd:
If you don’t like RED put a capital S on seconds.

Which is exactly why I asked the question in the first place. “seconds” is “known” to the compiler, so it highlights it, but why, and where do I find a list of “reserved” words the compiler might have issues with.

In this particular case it didn’t seem to matter, but are we saying that the programming language we use in Arduino IDE is in fact a much wider spectrum than the Reference dips into ? In other words, the language is C++, and the “Reference” is just for starters?

Google:

Arduino keywords.txt

"seconds" is "known" to the compiler

Nope. Highlighted in red by the Arduino IDE editor, for obscure reasons.

jremington:
Nope. Highlighted in red by the Arduino IDE editor, for obscure reasons.

omg ! there is treachery underfoot ??

daba:
omg ! there is treachery underfoot ??

Well without the sketch as "context" what do you really expect ?

Report closed.

seconds could be a reserved word in a library that we dont know about with the invisible sketch we cannot see.

"please fix my car...I dont know where it is or what is wrong with it and I cannot remember the make or model or colour either"

Could you perhaps take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

daba, this problem annoys me too. I just change a character or add some more characters to make the word different. I am pretty sure that if you did use an already reserved word (maybe it appears in a library for example) then you'd get a compiler warning to the effect you are declaring the same variable twice.

As for not posting code, in this case it does not matter, however, please consider in future that if you will not / cannot post your code for whatever reason then the help you will get will be very limited if you get any at all. Just as you don't have to post your code we don't have to help.

If you cannot post your code, or the code is overly long and complex, then the general solution is to write a small bit of code that demonstrates the problem and post that.

In this particular case it is not that important, because typing seconds into a completely empty sketch will still highlight it in red. It appears the IDE is reading in all the library keyword.txt files regardless of whether the library is used or not.

Hi,
second is highlighted, seconds is not.

second is highlighted in a new sketch with no libraries or functions.

Tom... :slight_smile:

TomGeorge:
Hi,
second is highlighted, seconds is not.

second is highlighted in a new sketch with no libraries or functions.

Tom... :slight_smile:

It depends on which libraries you have installed, even if you are not using them in the sketch. I get both second and seconds because second is used in the Time and RTClib libraries, while seconds is used in RTClib and Adafruit_GPS_Library. My observation is that the IDE processes all the keywords.txt files when it opens, and then highlights the keywords regardless of whether or not the library is being used. If I move the applicable libraries out of the Arduino/libraries folder and restart the IDE then the highlighting no longer occurs.

Multiple library spaces would make my life much easier - I've resorted to developing on multiple machines so I can keep certain things separate. There are so many problems with the simplistic way it's implemented. This is one of them.