我爲phidgets
C庫是一個C++的包裝,我現在有PhidgetDevice.h
一個通用Phidget設備,這裏是標題:包裝的Phidgets的工作不
#ifndef PHIDGET_DEVICE_H
#define PHIDGET_DEVICE_H
#include <phidget21.h>
#include <vector>
#include <iostream>
#include <string>
#define COMMON_IO_EVENT_CALLBACK(name) int CCONV name(CPhidgetHandle phid, void* userPtr)
#define ERROR_EVENT_CALLBACK(name) int CCONV name(CPhidgetHandle phid, void *userPtr, int errorCode, const char *errorString)
enum DeviceType
{
DEVICE_NULL,
DEVICE_KIT,
DEVICE_TEMPERATURE_SENSOR,
DEVICE_MOTION_SENSOR
};
class PhidgetDevice /* base class for every phidget device*/
{
public:
PhidgetDevice() : m_type(DEVICE_NULL) {}
explicit PhidgetDevice(DeviceType type) : m_type(type) {}
void SetType(DeviceType type) { m_type = type; }
virtual DeviceType GetType() { return m_type; }
virtual void CCONV SetAttachHandler(CPhidgetHandle IFK, int(__stdcall * callback) (CPhidgetHandle phid, void *userPtr), void *userptr) { CPhidget_set_OnAttach_Handler(IFK, callback, userptr); }
virtual void CCONV SetDetachHandler(CPhidgetHandle handle, int(__stdcall * callback) (CPhidgetHandle phid, void* userPtr), void * userptr) { CPhidget_set_OnDetach_Handler(handle, callback, userptr); }
virtual void CCONV SetErrorHandler(CPhidgetHandle handle, int(__stdcall * callback) (CPhidgetHandle phid, void* userPtr, int errorCode, const char *errorString), void * userptr) { CPhidget_set_OnError_Handler(handle, callback, userptr); }
protected:
DeviceType m_type;
};
#endif
這使得凌亂ÇPhidget功能看起來有點更好。 現在,這個編譯上的Visual Studio 2013罰款,但是當我嘗試使用g編譯它++ 4.8包括-std=c++11
我得到:
PhidgetDevice.h:34:72: error: expected ‘)’ before ‘*’ token virtual void CCONV SetAttachHandler(CPhidgetHandle IFK, int(__stdcall * callback) (CPhidgetHandle phid, void *userPtr), void *userptr) { CPhidget_set_OnAttach_Handler(IFK, callback, userptr); }
那些多,所有的抱怨函數指針雖然。
我的函數指針有什麼問題?