Variable declaration error (Damned either way)

I have a global variable 'xxx' that is used in two files, a .cpp and a .h

If I declare it in only one (either) I get the error:

'xxx' was not declared in this scope

If I include it in both I get the error:

multiple definition of 'xxx'

How do you fix this?

Post your code. Clearly you are not declaring it correctly.

You start by reading the locked topics at the top of this forum and properly post your code. I am unable to read your mind or guess what your code might look like.

NoobQ:
I have a global variable 'xxx' that is used in two files, a .cpp and a .h

If I declare it in only one (either) I get the error:

'xxx' was not declared in this scope

If I include it in both I get the error:

multiple definition of 'xxx'

How do you fix this?

A variable is not "used" in an include file. Its existence is declared there if you want to use it in a file other than your ino or cpp file.

For example, suppose you had a integer variable called "Page" that is declared as a global in a hypothetical cpp file called "lcd.cpp":

#include "lcd.h"

int Page = 5;

void ShowScreen()
{
    //do something
    while(false);

}

Your lcd.h would look like:

#ifndef _LCD_H
#define _LCD_H

extern int Page;


#endif

And in your sketch you'd include that .h file:

#include "lcd.h"

void setup()   
{                
    Serial.begin(9600);
    Serial.print( "Value of Page is " ); Serial.println( Page );
    while(1);
     
}//setup