Need help with pointer to pointer to function compile error

Hi,
I have some experience with C but new to C++ and classes. I am having trouble compiling some code that looks like it has to do with the function definition not being compatible with the implementation?

I get the error in the main.cpp file and a warning for the definition in the header file. I have also included parts of the Class defition to show what DWdevice is.

The code is being compiled in Atmel Studio 7. (think it is using gnu c++ compiler)

Any help much appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Code in Main CPP File:
  void newDevice(DW1000Device device);
  DW1000Ranging.attachNewDevice(newDevice);
  
  Error		invalid conversion from 'void (*)(DW1000Device)' to 'void (*)(DW1000Device*)' [-fpermissive]
  
  Code in Header File:
  static void attachNewDevice(void (* handleNewDevice)(DW1000Device*)) { _handleNewDevice = handleNewDevice; };
  
  Message		initializing argument 1 of 'static void DW1000RangingClass::attachNewDevice(void (*)(DW1000Device*))'
  
  static DW1000Device* getDistantDevice();
  static DW1000Device* searchDistantDevice(byte shortAddress[]);
 
  Class definition for DWDevice
  
  DWDevice Class:
  class DW1000Device {
public:
	//Constructor and destructor
	DW1000Device();
	DW1000Device(byte address[], byte shortAddress[]);
	DW1000Device(byte address[], boolean shortOne = false);
	~DW1000Device();
	
	//setters:
	void setAddress(char address[]);
	
	//getters
	unsigned int getReplyTime() { return _replyDelayTimeUS; }
	
	byte* getByteAddress();
	
	short getIndex() { return _index; }
	
	String getAddress();
	byte* getByteShortAddress();
	
	//functions which contains the date: (easier to put as public)
	// timestamps to remember
	DW1000Time timePollSent;

private:
	//device ID
	byte         _ownAddress[8];
	
	int _range;
	
	void randomShortAddress();
	
};
static void attachNewDevice(void (* handleNewDevice)(DW1000Device*))
Declares a function named attachNewDevice returning nothing and accepting a pointer to function returning nothing and accepting a pointer to DW1000Device.

void newDevice(DW1000Device device);
Declares a function named newDevice returning nothing and accepting (by value) a DW1000Device.

Maybe you meant
void newDevice(DW1000Device* device);

Note: According to the rule of zero, it appears like you should not define a destructor.
According to the rule of three, if you must define a destructor, you should almost always define a copy constructor and a copy-assignment operator as well.
Last edited on
Topic archived. No new replies allowed.