Christopher Haster / mbed-hal

Dependencies:   target-freescale

Fork of mbed-hal by Morpheus

Revision:
18:8c5ec1e88a9c
Parent:
17:fe43695d093a
Child:
19:f1c94b98286f
--- a/api/FunctionPointer.h	Tue Apr 05 20:36:18 2016 -0500
+++ b/api/FunctionPointer.h	Wed Apr 06 01:32:26 2016 -0500
@@ -72,7 +72,7 @@
      */
     void attach(R (*function)(A1, A2, A3, A4)) {
         _object = 0;
-        *reinterpret_cast<R (**)(A1, A2, A3, A4)>(_function) = function;
+        memcpy(&_function, &function, sizeof function);
         _thunk = &FuncPtr::staticthunk;
     }
 
@@ -84,7 +84,7 @@
     template <typename T>
     void attach(T *object, R (*function)(T*, A1, A2, A3, A4)) {
         _object = static_cast<void*>(object);
-        *reinterpret_cast<R (**)(T*, A1, A2, A3, A4)>(_function) = function;
+        memcpy(&_function, &function, sizeof function);
         _thunk = &FuncPtr::boundthunk<T>;
     }
 
@@ -96,7 +96,7 @@
     template<typename T>
     void attach(T *object, R (T::*method)(A1, A2, A3, A4)) {
         _object = static_cast<void*>(object);
-        *reinterpret_cast<R (T::**)(A1, A2, A3, A4)>(_function) = method;
+        memcpy(&_function, &method, sizeof method);
         _thunk = &FuncPtr::methodthunk<T>;
     }
 
@@ -106,7 +106,7 @@
      */
     void attach(const FuncPtr<R(A1, A2, A3, A4)> &func) {
         _object = func._object;
-        memcpy(_function, func._function, sizeof _function);
+        memcpy(&_function, &func._function, sizeof _function);
         _thunk = func._thunk;
     }
 
@@ -216,7 +216,7 @@
      */
     void attach(R (*function)(A1, A2, A3)) {
         _object = 0;
-        *reinterpret_cast<R (**)(A1, A2, A3)>(_function) = function;
+        memcpy(&_function, &function, sizeof function);
         _thunk = &FuncPtr::staticthunk;
     }
 
@@ -228,7 +228,7 @@
     template <typename T>
     void attach(T *object, R (*function)(T*, A1, A2, A3)) {
         _object = static_cast<void*>(object);
-        *reinterpret_cast<R (**)(T*, A1, A2, A3)>(_function) = function;
+        memcpy(&_function, &function, sizeof function);
         _thunk = &FuncPtr::boundthunk<T>;
     }
 
@@ -240,7 +240,7 @@
     template<typename T>
     void attach(T *object, R (T::*method)(A1, A2, A3)) {
         _object = static_cast<void*>(object);
-        *reinterpret_cast<R (T::**)(A1, A2, A3)>(_function) = method;
+        memcpy(&_function, &method, sizeof method);
         _thunk = &FuncPtr::methodthunk<T>;
     }
 
@@ -250,7 +250,7 @@
      */
     void attach(const FuncPtr<R(A1, A2, A3)> &func) {
         _object = func._object;
-        memcpy(_function, func._function, sizeof _function);
+        memcpy(&_function, &func._function, sizeof _function);
         _thunk = func._thunk;
     }
 
@@ -360,7 +360,7 @@
      */
     void attach(R (*function)(A1, A2)) {
         _object = 0;
-        *reinterpret_cast<R (**)(A1, A2)>(_function) = function;
+        memcpy(&_function, &function, sizeof function);
         _thunk = &FuncPtr::staticthunk;
     }
 
@@ -372,7 +372,7 @@
     template <typename T>
     void attach(T *object, R (*function)(T*, A1, A2)) {
         _object = static_cast<void*>(object);
-        *reinterpret_cast<R (**)(T*, A1, A2)>(_function) = function;
+        memcpy(&_function, &function, sizeof function);
         _thunk = &FuncPtr::boundthunk<T>;
     }
 
@@ -384,7 +384,7 @@
     template<typename T>
     void attach(T *object, R (T::*method)(A1, A2)) {
         _object = static_cast<void*>(object);
-        *reinterpret_cast<R (T::**)(A1, A2)>(_function) = method;
+        memcpy(&_function, &method, sizeof method);
         _thunk = &FuncPtr::methodthunk<T>;
     }
 
@@ -394,7 +394,7 @@
      */
     void attach(const FuncPtr<R(A1, A2)> &func) {
         _object = func._object;
-        memcpy(_function, func._function, sizeof _function);
+        memcpy(&_function, &func._function, sizeof _function);
         _thunk = func._thunk;
     }
 
@@ -504,7 +504,7 @@
      */
     void attach(R (*function)(A1)) {
         _object = 0;
-        *reinterpret_cast<R (**)(A1)>(_function) = function;
+        memcpy(&_function, &function, sizeof function);
         _thunk = &FuncPtr::staticthunk;
     }
 
@@ -516,7 +516,7 @@
     template <typename T>
     void attach(T *object, R (*function)(T*, A1)) {
         _object = static_cast<void*>(object);
-        *reinterpret_cast<R (**)(T*, A1)>(_function) = function;
+        memcpy(&_function, &function, sizeof function);
         _thunk = &FuncPtr::boundthunk<T>;
     }
 
@@ -528,7 +528,7 @@
     template<typename T>
     void attach(T *object, R (T::*method)(A1)) {
         _object = static_cast<void*>(object);
-        *reinterpret_cast<R (T::**)(A1)>(_function) = method;
+        memcpy(&_function, &method, sizeof method);
         _thunk = &FuncPtr::methodthunk<T>;
     }
 
@@ -538,7 +538,7 @@
      */
     void attach(const FuncPtr<R(A1)> &func) {
         _object = func._object;
-        memcpy(_function, func._function, sizeof _function);
+        memcpy(&_function, &func._function, sizeof _function);
         _thunk = func._thunk;
     }
 
@@ -648,7 +648,7 @@
      */
     void attach(R (*function)()) {
         _object = 0;
-        *reinterpret_cast<R (**)()>(_function) = function;
+        memcpy(&_function, &function, sizeof function);
         _thunk = &FuncPtr::staticthunk;
     }
 
@@ -660,7 +660,7 @@
     template <typename T>
     void attach(T *object, R (*function)(T*)) {
         _object = static_cast<void*>(object);
-        *reinterpret_cast<R (**)(T*)>(_function) = function;
+        memcpy(&_function, &function, sizeof function);
         _thunk = &FuncPtr::boundthunk<T>;
     }
 
@@ -672,7 +672,7 @@
     template<typename T>
     void attach(T *object, R (T::*method)()) {
         _object = static_cast<void*>(object);
-        *reinterpret_cast<R (T::**)()>(_function) = method;
+        memcpy(&_function, &method, sizeof method);
         _thunk = &FuncPtr::methodthunk<T>;
     }
 
@@ -682,7 +682,7 @@
      */
     void attach(const FuncPtr<R()> &func) {
         _object = func._object;
-        memcpy(_function, func._function, sizeof _function);
+        memcpy(&_function, &func._function, sizeof _function);
         _thunk = func._thunk;
     }