error: invalid use of void expression -> Classes

Hello all, I’m writing a library to hold some basic functions of a hydroponics controller and I’ve run into a little bit of a pickle. I’m receiving the following “error: invalid use of void expression” in each of the Alarm.timeOnce() method (the lines above the problems are commented with the error). I can not figure out how to debug this. Help would be appreciated, please let me know if I didn’t give enough information about the problem.

void HydroFunctions::setNextPump()
{
    if((hour() < _lights_out) && (hour() > _lights_out - _hours_on)){
      togglePin(_floodPump);
    //error: invalid use of void expression
    Alarm.timerOnce((time_t)_pump_on_time,togglePin(_floodPump));
    //error: invalid use of void expression
    Alarm.timerOnce((time_t)_seconds_between_floods, setNextPump());
  }
  else{
    int startHour = _lights_out-_hours_on;
    //error: invalid use of void expression
    Alarm.timerOnce(startHour + (24 - _lights_out) * 60 * 60, setNextPump());
  }
}

This is how the libraries are declared in the .cpp

#include "Arduino.h"
#include "HydroFunctions.h"
#include "C:\Users\Avi\Documents\Arduino\libraries\Time\Time.h"
#include "C:\Users\Avi\Documents\Arduino\libraries\DS3232RTC\DS3232RTC.h"
#include "C:\Users\Avi\Documents\Arduino\libraries\TimeAlarms\TimeAlarms.h"

And this is the prototype in the .h file

int locateNextFlood();
void togglePin(int);
void mix(int pin, int s);
void setNextPump();
    Alarm.timerOnce((time_t)_seconds_between_floods, setNextPump());

The second argument is the NAME of the function to call, not a call to a function. Lose the ().

But what if the function requires parameters?

I removed the parenthesis and now have these errors

In file included from HydroFunctions.cpp:4:
C:\Users\Avi\Documents\Arduino\libraries\DS3232RTC\DS3232RTC.h:40:18: warning: Time.h: No such file or directory
HydroFunctions.cpp: In member function 'void HydroFunctions::setNextPump()':
HydroFunctions.cpp:118: error: no matching function for call to 'TimeAlarmsClass::timerOnce(time_t, <unresolved overloaded function type>)'
C:\Users\Avi\Documents\Arduino\libraries\TimeAlarms\TimeAlarms.h:77: note: candidates are: AlarmID_t TimeAlarmsClass::timerOnce(time_t, void (*)())
C:\Users\Avi\Documents\Arduino\libraries\TimeAlarms\TimeAlarms.h:78: note:                 AlarmID_t TimeAlarmsClass::timerOnce(int, int, int, void (*)())
HydroFunctions.cpp:119: error: no matching function for call to 'TimeAlarmsClass::timerOnce(time_t, <unresolved overloaded function type>)'
C:\Users\Avi\Documents\Arduino\libraries\TimeAlarms\TimeAlarms.h:77: note: candidates are: AlarmID_t TimeAlarmsClass::timerOnce(time_t, void (*)())
C:\Users\Avi\Documents\Arduino\libraries\TimeAlarms\TimeAlarms.h:78: note:                 AlarmID_t TimeAlarmsClass::timerOnce(int, int, int, void (*)())
HydroFunctions.cpp:123: error: no matching function for call to 'TimeAlarmsClass::timerOnce(int, <unresolved overloaded function type>)'
C:\Users\Avi\Documents\Arduino\libraries\TimeAlarms\TimeAlarms.h:77: note: candidates are: AlarmID_t TimeAlarmsClass::timerOnce(time_t, void (*)())
C:\Users\Avi\Documents\Arduino\libraries\TimeAlarms\TimeAlarms.h:78: note:                 AlarmID_t TimeAlarmsClass::timerOnce(int, int, int, void (*)())
HydroFunctions.cpp: In member function 'void HydroFunctions::correctPH(float)':
HydroFunctions.cpp:180: warning: unused variable 'pH'
HydroFunctions.cpp: In member function 'void HydroFunctions::correctEC(float)':
HydroFunctions.cpp:206: warning: unused variable 'start'

But what if the function requires parameters?

Then it isn't appropriate for that use.

Think of that function as what gets called when a delivery person rings your doorbell. What possible argument could the doorbell possibly need?

n4alpaca:
But what if the function requires parameters?

What sort of parameters? You could use a function object, but your case may not require that.

Besides, your example did not have parameters, so is this a hypothetical question?

I've decided to go another route and rework the code. Thanks for the answers