analogReadResolution(12) - will not upload to Due

I am new to Arduino and enjoying the experience. I am trying to set the analogReadResolution() of a Due to 12 bit as explained in this tutorial http://arduino.cc/en/Reference/AnalogReadResolution but get the following error:

In function 'void loop()':
sketch_jul28a:9: error: 'analogReadResolution' was not declared in this scope

I have tried both software versions 1.0.5 and 1.5.2, the board is correctly set to Due and I have been able to successfully use the board at normal 10 bit resolution in other tutorials. The code is as follows, any help or guidance appreciated:

void setup() {
  // open a serial connection
  Serial.begin(9600); 
}

void loop() {
  // read the input on A0 at default resolution (10 bits)
  // and send it out the serial connection 
  analogReadResolution(10);
  Serial.print("ADC 10-bit (default) : ");
  Serial.print(analogRead(A0));

  // change the resolution to 12 bits and read A0
  analogReadResolution(12);
  Serial.print(", 12-bit : ");
  Serial.print(analogRead(A0));

  // change the resolution to 16 bits and read A0
  analogReadResolution(16);
  Serial.print(", 16-bit : ");
  Serial.print(analogRead(A0));

  // change the resolution to 8 bits and read A0
  analogReadResolution(8 );
  Serial.print(", 8-bit : ");
  Serial.println(analogRead(A0));

  // a little delay to not hog serial monitor
  delay(100);
}

Read this before posting a programming question

Code tags please.

What board is selected under 'Tools'->'Board'? I also encountered the problem once, in my case the software selected another board, instead of my Arduino Due.

Just back from vacation, apologies for the late reply. I double checked and Due is selected.

Still scratching my head with this one. To have the extra resolution would be really useful and it's infuriating to think that the board should run this sketch but I cannot work out why it doesn't.

I just tested your code and is running OK in my Due. I noticed the reference for analogReadResolution is contained in the following files:
wiring_analog.c
wiring_analog.h
These files are located at:

..\arduino-1.5.2-windows\arduino-1.5.2\hardware\arduino\sam\cores\arduino

Check that out. Regards!

I checked the wiring_analog.c and .c files - they are both present. I also found that if I choose Arduino Due (Programming Port) or Arduino Due (Native USB Port) the sketch compiles without any errors BUT I cannot upload as the board is not found. When I revert to Arduino Due I can upload other sketches but still cannot get the analogReadResolution(12) to compile.

Hello AlexJK,
May be this is redundant but remember that the most of the time you switch between USB ports in Due, the active virtual COM port changes. Thus, every time you switch between port verify in Tools->Serial Port that you active virtual COM port is checked. Also, what do you mean with "the board is not found"?
It could be useful if you post here the verbata you are getting after trying to upload your sketch. Are you getting something like:

Binary sketch size: 10,796 bytes (of a 524,288 byte maximum) - 2% used
Forcing reset using 1200bps open/close on port COM12
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
Uploading using selected port: COM12
C:\Users\Myself\Downloads\arduino-1.5.2-windows\arduino-1.5.2/hardware/tools/bossac.exe --port=COM12 -U true -e -w -v -b C:\Users\Myself\AppData\Local\Temp

\build7800558003391814885.tmp/sketch_aug16a.cpp.bin -R
No device found on COM12

?
Regards!

I have tried both software versions 1.0.5 and 1.5.2, the board is correctly set to Due and I have been able to successfully use the board at normal 10 bit resolution in other tutorials. The code is as follows, any help or guidance appreciated:

software versions 1.0.5 doesn't support the Due... I would think that "analogReadResolution(12)" must fail to compile on ver 1.0.5 unconditionally and should as well in ver 1.5.2, If you had the wrong board selected... The ATMega 328P-PU and for that matter all the ATMega parts only are capable of 10 bits of A/D resolution.

Doc