not declared in this scope

It been a long time since my C days and have forgotten most of it. I hope someone can help me out with this basic issue.
I am trying to add some IRremote code to phi_prompt software to enable the use of a remote control.
I have the following in phi_prompt.cpp

#include "IRremote.h"
#include "IRremoteInt.h"
.
.
.
//Interactions
int wait_on_escape(int ref_time) // Returns key pressed or 0 if time expires before any key was pressed.
{
//Wait on button push.
  long temp0;
  byte temp1;
  temp0=millis();
 while(irrecv.decode(&results))
   {
     switch (results.value)
     {
       case 0xC001FFF4: //up
       Serial.println("You pressed up");
       return (1);
       break;

       case 0xC001FFDC: //down
       Serial.println("You pressed down");
       return (2);
       break;

       case 0xC001FFD8: //left
	   Serial.println("You pressed left");
       return (3);
       break;

       case 0xC001FFC4: //right
	   Serial.println("You pressed right");
       return (4);
       break;

       case 0xC001FFF8://enter
	   Serial.println("You pressed enter");
       return (5);
       break;

       case 0xC001FFC0: //off
	   Serial.println("You pressed Off");
       return (6);
       break;

       default:
       return(0);
       break;

     }irrecv.resume(); // Receive the next value
	}

  return (0);
}

I have the typical entries in the .pde

#include <IRremote.h>

int RECV_PIN = 12;
IRrecv irrecv(RECV_PIN);
decode_results results;

and

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

on compile I am getting the following error

phi_prompt\phi_prompt.cpp: In function 'int wait_on_escape(int)':
phi_prompt\phi_prompt.cpp:424: error: 'irrecv' was not declared in this scope
phi_prompt\phi_prompt.cpp:424: error: 'results' was not declared in this scope

Any help would be appreciated!
Dave

Variables created in the sketch are not automatically available in other files. In your case, this includes irrecv and results.

You could tell the cpp file that those variables exist, and are defined in another file, using the extern keyword.

extern IRrecv irrecv;
extern decode_results results;

Thanks very much Paul, that fixed that issue. :slight_smile: