]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Fixing problem with CINT callback routine.
authoraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 4 Nov 2009 14:27:55 +0000 (14:27 +0000)
committeraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 4 Nov 2009 14:27:55 +0000 (14:27 +0000)
HLT/trigger/AliHLTGlobalTriggerWrapper.cxx

index 8c130706c40d0260c7635527fb3d6f12b224076b..ad2ed97043894bb830671fab99e3bc42ad4f1564 100644 (file)
@@ -119,11 +119,28 @@ AliHLTGlobalTriggerWrapper::AliHLTGlobalTriggerWrapper(const char* classname) :
     HLTError("Could not create a new object of type '%s'.", classname);
   }
   
-  // Matthias 2009-11-03: temporarily disabled, on some systems the warning
-  // is interpreted an an error, so we have a litle problem with root
-  // HLT/trigger/AliHLTGlobalTriggerWrapper.cxx:122: error: ISO C++ forbids
-  // casting between pointer-to-function and pointer-to-object
-  //G__set_errmsgcallback(reinterpret_cast<void*>(AliHLTOnErrorInCINT));
+  // The following is a workaround for casting void* to void (*)(), i.e. a pointer to object to
+  // a pointer to function. Unfortunately the G__set_errmsgcallback routine interface is defined
+  // using a pointer to object so this workaround is necessary.
+  // We check that the two types are the same size. If they are not then such an operation is
+  // unsafe on the platform on which we are running and will not be performed.
+  union
+  {
+    void* fPtr;
+    void (*fFuncPtr)(char*);
+  };
+  fFuncPtr = AliHLTOnErrorInCINT;
+  if (sizeof(fPtr) == sizeof(fFuncPtr))
+  {
+    G__set_errmsgcallback(fPtr);
+  }
+  else
+  {
+    HLTWarning("On this platform a pointer to function and pointer to object are different sizes."
+      " For this reason we cannot use the G__set_errmsgcallback CINT API call in a safe way so all"
+      " error messages generated by CINT will not be captured or logged in the HLT system."
+    );
+  }
 }