Is "delay(ms);" working properly? FIXED!!!

I'm new to Arduino programming but very experienced in general C++. This is an oddity to me, hope it is known to some of you.

I have a largeish program which compiles and runs perfectly. If I add in a line: "delay(25);" it won't build. If I comment out only that line it is fine again. With verbose reporting on everything looks fine until the linker when it reports:

collect2.exe: error: ld returned 5 exit status

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

I'm told the "ld" shows a linker error, hope that's correct. I wasn't aware that delay(ms) needed a #include, it has worked for me in the past with simple "hello world" stuff. Can anyone advise me as to what is wrong?

EDIT: Should have said this is on Windows XP. I know there has been some discussion re delay(ms) on Linux.

Are you using either Windows XP or Windows 10?

There was a compiler bug that caused the error (seemingly at random, so actually nothing to do with the delay function). Originally it only happened with Windows XP (so there was no incentive for a fix), but recently it started happening sometimes with Windows 10.

There is now a bugfix version of the IDE to correct this.

BTW. See the test build here: Update bundled tools by facchinm · Pull Request #5863 · arduino/Arduino · GitHub

This build fixed the problem for me. :slight_smile:

Thanks for the replies Stuart. (Looking through them, your fame goes before you! :slight_smile: )

I tried to post an edit to my original post to say what Windows version I was using as I realised it may be a factor. The system wouldn’t let me post it for 5 minutes and we must have passed posts while waiting. My apologies.

The links in the link you posted just come up with Error 404 for me! I’m not having lot of luck today. Could that mean that the work is either retracted or already in place?

By the way my current IDE is 1.8.1 which I thought was the most up to date. Is this an IDE issue or a gcc compiler one? I’m assuming that the IDE installs its own versions of gcc. Is that correct?

Yeah that five minute thing is a real pain. I cant believe they make you do 100 posts before that thing goes away :confused: In my experience it's pretty obvious whether someone is a genuine user or just a spammer after only one or two posts. Anyway ...

The link works fine for me, but I didn't make it a proper link so you had to cut and paste it. Perhaps you just cut and pasted it wrongly? Anyway, here it is as a proper link.

bordonbert:
EDIT: Should have said this is on Windows XP. I know there has been some discussion re delay(ms) on Linux.

Yeah well that's the problem for sure then. The bugfix version of the IDE in the above link (PR-5863-BUILD-638-windows) will definitely fix it.

Damn! I hate it when this happens. Just saved the sketch, closed the IDE, reopened it, compiled, voila! It now doesn't have the problem. Well at least I have a workaround.

I'll keep my eyes open for where to get the fixed version. Don't know if there is anything more you or anyone else can recommend, I would be grateful?

Hahaha! We're suffering from that crossing in the post thing again. Thanks, I'll try the new link and hopefully get it sorted. You've been really helpful Stuart, I appreciate it.

(100 posts? So I start a new thread and hold a long conversation with myself? :o )

The links you have posted DO work but the links in the post you send me to don't, including the original! It's not your own link which gives Error 404, it's theirs. That's why I wondered if they could now be superfluous as the fix was in place.

The fix is now in the hourly build.

Thanks guys. I have the new version copied in and it looks good at first try. If there are any further problems I’ll make sure to update you on them. Your help is much appreciated.