A method in class with "std::function<void> " parameter not allowing

Hi,

I have a simple class. Its named "CommonApp".

It has a setup method. Its takes the std::function parameter.

CommonApp.h

#pragma region Imports
#include <ESP8266WiFi.h>
#pragma endregion

class CommonApp
{
public:
	CommonApp();
	~CommonApp();
	void Setup(std::function<void> pinSetFunc);
	void Loop();
};

CommonApp.cpp

#include "CommonApp.h"
#include <ESP8266WiFi.h>


CommonApp::CommonApp()
{
}


CommonApp::~CommonApp()
{
}

void CommonApp::Setup(std::function<void> pinSetFunc)
{

}

void CommonApp::Loop() {

}

Visual studio gives error in CommonApp.cpp file at line "void CommonApp::Setup(std::function pinSetFunc)"

Error Message

CommonApp.cpp: In member function void CommonApp::Setup(std::function<void>)
 
CommonApp.cpp: 14:6: error: 'pinSetFunc' has incomplete type
 void CommonApp*: Setup(std::function<void> pinSetFunc)
ESP8266WiFiGeneric.h:27: In file included from
Error compiling libraries
ESP8266WiFiSTA.h:28: from
Build failed for project 'MyApp.ESP8266.Model1'
ESP8266WiFi.h:34: from
CommonApp.h:2: from
CommonApp.cpp:1: from
 
functional:1866: error  declaration of class std  function<void>
   class function

Error message


wildebeest stampede

It appears the type requires more punctuation...

void Setup(std::function<void()> pinSetFunc);

Additionally, if called without a target object, that class will throw a 'bad_function_call' exception. How is that handled since (I believe) the Arduino environment does not implement exceptions?

I changed function to function<void()> in .cpp and .h ,Its successful!

Thank you very much! :slight_smile:

gfvalvo:
Additionally, if called without a target object, that class will throw a 'bad_function_call' exception. How is that handled since (I believe) the Arduino environment does not implement exceptions?

Thank you too bro :slight_smile:

You are welcome.