Arduino IDE Code Not Compiling

I’ve been having a problem with the arduino IDE version 0022 for the past few months that has really been bugging me.

It happens when I make modifications to already saved code. Randomly sometimes the code will compile as if I had not made any changes! Even if I save the new changes. For example here is the example code for master_writer “part of the wire library”.

#include <Wire.h>

void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
}

byte x = 0;

void loop()
{
  Wire.beginTransmission(4); // transmit to device #4
  Wire.send("x is ");        // sends five bytes
  Wire.send(x);              // sends one byte  
  Wire.endTransmission();    // stop transmitting

  x++;
  delay(500);
}

This Runs Fine but if I make the modifications below:

#include <Wire.h>

void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
}

byte x = 0;

void loop()
{
  Wire.beginTransmission(4); 
  Wire.send("Robotman"); <------------------------------------
  Wire.send("Robotman"); <------------------------------------   
  Wire.endTransmission();    // stop transmitting

  x++;
  delay(500);
}

Nothing happens! The compiler acts as if only half changes where made and what gets sent is “Robotman 1” not “Robotman Robotman” . Also if I restart the IDE and use copy paste with the code the same problem occurs. Its like “Wire.send(x);” is hidden inside the text. The only way to fix it is to restart the IDE and type the whole program up form scratch. This is a really big problem when it occurs in larger programs because I have to retype it all for it to work again.

If anybody can shed some light on how to fix this it would be greatly appreciated.

Can you post the compile and the upload output? Hold the shift key down for verbose.

Decided to attach a text file :slight_smile:

The output for this is “Robotman” “Robotma110” ? Its like the above code was horribly corrupted. Also the number no longer increments.

output.txt (26.6 KB)

Also the number no longer increments.

x stops incrementing? How do you know?

Not x it still increments but the number at the end of "Robotma110" stops incriminating unlike in the original working code which printed "x is 1" "x is 2" and so on... Its as if the code has become so corrupted there is now a hidden command saying "Wire.send("Robotma110");" . I can continue to just retype all of my code but I'd really like to know why this corruption is occurring and how to fix it.

You should check the value returned by Wire.endTransmission().

0 = "success"
1 = "data too long to fit in transmit buffer"
2 = "received NACK on transmit of address"
3 = "received NACK on transmit of data"
4 = "other error"

Actually I think I solved the problem myself. I was using a third party clipboard manager called Ditto and I think it was corrupting the copy/paste. I had to do a reinstall of my OS because I got a new SSD and I left Ditto out, now everything works fine.