volatile variable as a parameter in a function

Hello,
I have a volatile variable:
volatile boolean isPowerSupplyDown = false;

I want this variable to be a parameter in a function.
The kind of this is to not made the temperature acquisition if the variable isPowerSupplyDown goes up.

So the question is:
Is that needed to pass a pointer to the variable or the variable itself ?

That's a part of my library:
MIN_MAX BatteryBox::getMiniMaxi(volatile boolean *isPowerDown){
for (byte i = 0; i < nbSensors; i++){
if (*isPowerDown)
break;
.............
}

I just want to exit from the loop if the variable isPowerDown goes up.

Many thanks for your help.

Best regards

Thierry

easiest is to make the volatile global...

The volatile keyword tells the compile that the value can change outside of the function that is executing. An input argument can NEVER change. What was passed by value to the function can not change.

What you are trying to do does not make sense. As rob says, a global (volatile) variable is the solution.

Hello,
I understamd the respomse, but the function is in the library.
So even if the varialbe is global, it can't be see in the library...

Best regards,

Thierry

the function is in the library

Which library?

my own library:
for example, a function int the library...

MIN_MAX BatteryBox::getMiniMaxi(volatile boolean *isPowerDown){

MIN_MAX minMax;
minMax.min = 100;
minMax.max = -60;

if (startTempAqu > millis())
startTempAqu = millis();

if ((millis() - startTempAqu) > MAX_AGE_TEMP || !initialized){
startTempAqu = millis();

sensors.requestTemperatures();
unsigned long delayInMillis = 750 / (1 << (12 - PRECISION));

// wait the conversion to be complette
while (millis() < (startTempAqu + delayInMillis) && !isPowerDown){
;
}

for (byte i = 0; i < nbSensors; i++){
if (*isPowerDown)
break;
.....

There's no rule against making a variable in a library, volatile. Just stick the word in there. It works!

Vorms:
Hello,
I understamd the respomse, but the function is in the library.
So even if the varialbe is global, it can't be see in the library...

Yes, it can. Example:

#include "foo.h"
void powerdetect ()
  {
  foo::isPowerDown = true;
  }
void setup ()
  {
  attachInterrupt (0, powerdetect, FALLING);
  }  // end of setup

void loop () { }

foo.cpp:

#include "foo.h"

volatile bool foo::isPowerDown;

foo.h:

class foo 
  {
  public:

  static volatile bool isPowerDown;  
  };

So even if the varialbe is global, it can't be see in the library... ... Yes, it can. Example:

I suspect that what OP meant was that if the variable is defined in the sketch, it can't be seen in the library. Obviously that isn't true, either. OP needs to learn about compilation units and the extern keyword.

Why not use a reference (and a real bool seeing as its the weekend):

MIN_MAX BatteryBox::getMiniMaxi(volatile bool &isPowerDown){