Pass by reference or value

Hello guys , new to coding and i am currently using an arduino mega and a cnc shield v3

currently when i run this snip of code it returns an error

Xlimit not defined in scope

i understand this variable is local in CNC_setup()
is their any way to go around making it a global variable

void CNC_setup() {
  // defines pins numbers
  const int stepX = 2;
  const int dirX  = 5;

  const int stepY = 3;
  const int dirY  = 6;

  const int stepZ = 4;
  const int dirZ  = 7;

  const int enPin = 8;

  const int Xlimit = 9 ;
  const int Ylimit = 10;
  const int Zlimit = 11;


  pinMode(stepX, OUTPUT);
  pinMode(dirX, OUTPUT);

  pinMode(stepY, OUTPUT);
  pinMode(dirY, OUTPUT);

  pinMode(stepZ, OUTPUT);
  pinMode(dirZ, OUTPUT);

  pinMode(enPin, OUTPUT);
  digitalWrite(enPin, LOW);

  digitalWrite(dirX, HIGH);

  digitalWrite(dirY, LOW);
  digitalWrite(dirZ, HIGH);

  pinMode(Xlimit, INPUT);
  pinMode(Ylimit, INPUT);
  pinMode(Zlimit, INPUT);
}

void Calibrate() {
  CNC_setup();
  if (Xlimit == LOW) {
    digitalWrite(stepX, HIGH);
    if (Xlimit == HIGH) {
      digitalWrite(stepX, LOW);
    }
  }

  if (Ylimit == LOW) {
    digitalWrite(stepY, HIGH);
    if (Ylimit == HIGH) {
      digitalWrite(stepY, LOW);


    }
  }

  if (Zlimit == LOW) {
    digitalWrite(stepZ, HIGH);
    if (Zlimit == HIGH) {
      digitalWrite(stepZ, LOW);
    }
  }
}
void Motor_Movment(boolean dir, byte dirPin, byte stepperPin, int steps)

{

  digitalWrite(dirPin, dir);

  delay(100);

  for (int i = 0; i < steps; i++) {

    digitalWrite(stepperPin, HIGH);

    delayMicroseconds(delayTime);

    digitalWrite(stepperPin, LOW);

    delayMicroseconds(delayTime);

  }

}

Sure. Declare it outside void CNC_setup().

What does this have to do with passing by reference or value? I don't see anything like that.

Since Xlimit is declared as a constant, the compiler will replace every occurrence of Xlimit in the code with its actual value of 9, and never allocate any storage. So declaring it globally will not have any affects on the amount of dynamic memory used.

Which leads to another problem:

const int Xlimit = 9 ;

Just when is 9 going to be equal to LOW?

  if (Xlimit == LOW) {

Pin numbers should not be declared in a function, because they might be used in many different functions. They should be named so it's obvious that it's a pin, for the reason that it might be misused as above. For example XlimitPin.