.h to .d advice needed

Derek Parnell derek at nomail.afraid.org
Mon Aug 7 18:06:04 PDT 2006


On Tue, 8 Aug 2006 02:53:18 +0200, Emp wrote:

> Thx, I thought there was only one, the dsource one that is.
> 
> I've succesfully run the windows version on my headerfile, but I'm a bit 
> suspicious about the output.
> (cmd: 'htod NIDAQmx.h' and it should be an ANSI C header)
> All the error codes have been commented out:
> //C     #define DAQmxErrorCOCannotKeepUpInHWTimedSinglePoint 
> (-209805)
> And '-209805' is nowhere else to be found (in a global search).
> 
> Another question(not about the header file, but some example code :)
> How do I translate this to D?
> #define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) 
> goto Error; else
> 
> It is used like this:
> DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
> 
> Thx.

Yuck! Why do people make it hard for themselves ;-)

 void DAQmxErrChk( int(?) functionCall ) 
 {
   if (DAQmxFailed (error = functionCall))
      throw new DAQException("whatever");
 }

Then replace the 'Error:' label with ...

  scope(failure)
  {
    // Handle any exception thrown during this scope.
    if (error == ...) ...
  }


-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
8/08/2006 10:56:34 AM



More information about the Digitalmars-d-learn mailing list