Announcement

Collapse
No announcement yet.

C/C++ help

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

  • C/C++ help

    I'm attempting to convert some C/C++ function declarations to PB and my
    C/C++ is very very rusty. There are some things I don't understand, for
    starters the following typedef statements:

    Code:
    ///*************************
    //   TYPE Declarations
    ///*************************
    typedef ALGproject;
    typedef ALGalign;
    typedef ALGpnt;
    typedef ALGvpnt;
    typedef ALGtopnt;
    typedef ALGele;
    I thought "typedef" also required a data type like int, double etc.
    as part of the syntax. Is this an assumed data type of "int"?

    Here's a function declaration line that relates to the above typedef:

    Code:
    nativeCode int stdcall scadSDK_cogoGetProjects( ALGproject **prjs, int *cnt );
    I understand "*cnt" is a pointer of type "int", but "**prjs" is a
    pointer(???) of type ALGproject??? How can this be when ALGproject
    has not been declared as a specific data type or struct? The VB
    declarations I also received with the C/C++ files declare both
    "prjs" and "cnt" as long. So would I be correct in declaring this
    function in PB as:

    Code:
    Declare Function scadSDK_cogoGetProjects Lib "SCadSDKMK" ALIAS "scadSDK_cogoGetProjects" _
    (BYVAL pProject as PTR, BYVAL pCount as PTR) as Long
    Am I on the right track here?




    ------------------
    Later...

    JR

    PowerBASIC is alive
    in Colorado
    Later...

    JR

    "When governments fear the people there is liberty. When people fear the government there is tyranny." - Thomas Jefferson

  • #2
    When you read that is a pointer to a variable that will receive... something,
    what it means is that you have to pass the address of that variable. In BASIC
    you achieve it with BYREF.

    Declare Function scadSDK_cogoGetProjects Lib "SCadSDKMK" ALIAS "scadSDK_cogoGetProjects" _
    (BYREF prjs AS DWORD, BYREF cnt AS LONG) as Long

    prjs could be another thing, instead of DWORD, depending of what ALGproject
    means. VB always uses Longs because it has not Dwords.


    ------------------
    Website: http://com.it-berater.org
    SED Editor, TypeLib Browser, COM Wrappers.
    Forum: http://www.forum.it-berater.org
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Yes, typedef does require a pre-defined object or variable to be used.

      This "ALGproject" obviously has been defined most likely in one of the
      header files. Check your includes at the top of the "C/C++" file.

      prjs appears to be an array of strings. However, the normal
      definition is usually "pjs *[]" but **prjs works too.

      Hope this helps.

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

      Comment

      Working...
      X