Announcement

Collapse
No announcement yet.

convert C declaration to PowerBasic

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

  • convert C declaration to PowerBasic

    I'm trying to convert a C header file to PowerBasic, so that
    I can write a DLL.

    The functions I am writing is have various arguments which
    I am unsure how to code in PB.

    Specifically they are:
    void **data
    void *data
    const char data[64]
    const char *data
    char data[256]
    const char *datalist[]
    itemInfo itemList[], where itemInfo is a structure

    Does anyone know how to convert this to PB ?

    Thanks for any help, -Dave


    ------------------

  • #2
    Code:
    void **data = Pointer to any data type, so declare "As Any"
    void *data = Pointer to any data type, so declare "As Any"
    const char data[64] = Asciiz character array (As Asciiz * 64)
    const char *data = Pointer to Asciiz character array (As Asciiz Ptr)
    char data[256] = Asciiz character array (As Asciiz * 256)
    const char *datalist[] = Possibly a pointer to an array of arrays (I'm not sure just by this code)
    itemInfo itemList[], where itemInfo is a structure = Pointer to array of itemInfo (itemList() As ItemInfo)
    With the last one, you might have to declare it as a Dword and pass the first array element (VarPtr(itemList(0))

    I can't be 100% sure on these declarations just by the code you posted, but it should be pretty close

    ------------------
    Kev Peel
    http://www.kgpsoftware.com
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


    • #3
      I get a compiler error when I try to use the "ANY" data type.

      Is there some compiler flag that I need to set to allow this?

      Also, should I be using SDECL or CDECL?

      Thanks,

      -Dave

      ------------------

      Comment


      • #4
        I just re-read your original message and I see that you want to reproduce the C DLL as a PB DLL (I thought you just wanted header declarations). So, in this case I think you should declare the two "void" parameters to "ByVal pData As Dword" because they point to an unknown buffer.

        I'm not sure about the calling convention because you just posted the parameter definitions and not the whole declaration. The default calling convention in C is CDECL, in PowerBASIC it is SDECL.

        ------------------
        Kev Peel
        http://www.kgpsoftware.com
        kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

        Comment


        • #5
          See also Comparative Data Types in the Data Types section
          of your PB/Win manual or help file.

          ------------------
          Tom Hanlin
          PowerBASIC Staff

          Comment

          Working...
          X