Compiling problems, while following DS18B20 tutorial

I am getting the following error message, when compiling the code, posted below. This code was cut&pasted from a tutorial, and I am clueless as to why it isn't working properly.

error message:

/Users/rootsman/Documents/Arduino/libraries/OneWire/OneWire.cpp:85:24: error: WConstants.h: No such file or directory
/Users/rootsman/Documents/Arduino/libraries/OneWire/OneWire.cpp: In constructor 'OneWire::OneWire(uint8_t)':
/Users/rootsman/Documents/Arduino/libraries/OneWire/OneWire.cpp:93: error: 'digitalPinToBitMask' was not declared in this scope
/Users/rootsman/Documents/Arduino/libraries/OneWire/OneWire.cpp:94: error: 'digitalPinToPort' was not declared in this scope
/Users/rootsman/Documents/Arduino/libraries/OneWire/OneWire.cpp:94: error: 'portInputRegister' was not declared in this scope
/Users/rootsman/Documents/Arduino/libraries/OneWire/OneWire.cpp: In member function 'uint8_t OneWire::reset()':
/Users/rootsman/Documents/Arduino/libraries/OneWire/OneWire.cpp:127: error: 'delayMicroseconds' was not declared in this scope
/Users/rootsman/Documents/Arduino/libraries/OneWire/OneWire.cpp:134: error: 'delayMicroseconds' was not declared in this scope
/Users/rootsman/Documents/Arduino/libraries/OneWire/OneWire.cpp: In member function 'void OneWire::write_bit(uint8_t)':
/Users/rootsman/Documents/Arduino/libraries/OneWire/OneWire.cpp:157: error: 'delayMicroseconds' was not declared in this scope
/Users/rootsman/Documents/Arduino/libraries/OneWire/OneWire.cpp:165: error: 'delayMicroseconds' was not declared in this scope
/Users/rootsman/Documents/Arduino/libraries/OneWire/OneWire.cpp: In member function 'uint8_t OneWire::read_bit()':
/Users/rootsman/Documents/Arduino/libraries/OneWire/OneWire.cpp:185: error: 'delayMicroseconds' was not declared in this scope

Does this message mean that my OneWire.cpp file is corrupt, obsolete, or is missing some key parameter?

Here is the code:

#include <OneWire.h>

/* DS18S20 Temperature chip i/o */

OneWire  ds(10);  // on pin 10

void setup(void) {
  Serial.begin(9600);
}

void loop(void) {
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];
  
  if ( !ds.search(addr)) {
    Serial.print("No more addresses.\n");
    ds.reset_search();
    delay(250);
    return;
  }
  
  Serial.print("R=");
  for( i = 0; i < 8; i++) {
    Serial.print(addr[i], HEX);
    Serial.print(" ");
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
      Serial.print("CRC is not valid!\n");
      return;
  }
  
  if ( addr[0] != 0x10) {
      Serial.print("Device is not a DS18S20 family device.\n");
      return;
  }

  // The DallasTemperature library can do all this work for you!

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1);         // start conversion, with parasite power on at the end
  
  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.
  
  present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE);         // Read Scratchpad

  Serial.print("P=");
  Serial.print(present,HEX);
  Serial.print(" ");
  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
    Serial.print(data[i], HEX);
    Serial.print(" ");
  }
  Serial.print(" CRC=");
  Serial.print( OneWire::crc8( data, 8), HEX);
  Serial.println();
}

The reference to WConstants.h suggests that your OneWire library is very old (it should be referring to Arduino.h) and that in turn suggests that your whole Arduino installation is old.
Which version of the Arduino IDE are you using? The current version is 1.6.5

Pete

Aaah…this makes sense! I have been trying several different tutorials for this project…some of them are a couple of years old, and since they all begin with "download the libraries…", I just kept the same ones from the first time, thinking they were all the same…and I'm using arduino 1.05!

Thank you very much, el supremo.

I will be upgrading my arduino install, deleting the old files, and trying this out…