Announcement

Collapse
No announcement yet.

C to Pb - NULL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    C to Pb - NULL

    hi,
    i'm having problems trying to make a library work for which i only have c examples and headers, where i have to pass a NULL parameter to a function..

    the c declaration:

    int32 __CFUNC DAQmxReadAnalogF64 (TaskHandle taskHandle, int32 numSampsPerChan, float64 timeout, bool32 fillMode, float64 readArray[], uInt32 arraySizeInSamps, int32 *sampsPerChanRead, bool32 *reserved);


    my translation:

    DECLARE FUNCTION DAQmxReadAnalogF64 LIB "nicaiu.dll" ALIAS "DAQmxReadAnalogF64" (BYVAL TaskHandle AS DWORD, BYVAL numSampsPerChan AS LONG, BYVAL timout AS DOUBLE, BYVAL fillMode AS DWORD,_
    BYREF buffer() AS DOUBLE, BYVAL arraySizeInSamps AS LONG, BYREF sampsPerChanRead AS LONG, BYREF reserved AS DWORD) AS LONG


    Now the problem is that the function insists that the last parameter, 'reserved' is a NULL. I tried just filling in literal 0, a variable with value 0 and a pointer to a variable with value 0, but that does not work. The program compiles and runs, but the function returns a error "Reserved parameter must be NULL".
    So can someone explain what exactly that 'NULL' is in c and how you pass it from powerbasic?

    many thanks!

    #2
    Use BYVAL %NULL to force a NULL pointer.

    You may also have problems with BYREF buffer() AS DOUBLE as the PB array type is not compatible with C, use instead: BYVAL buffer AS DOUBLE PTR.
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


      #3
      Another thing you might want to look at is the arraySizeInSamps. The C declaration lists it as a uInt32 which, I believe, is an unsigned, 32 bit integer so DWORD would be more appropriate than LONG.
      Jeff Blakeney

      Comment


        #4
        after following Kev and Jeff's suggestions it works
        thanks!

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎