Announcement

Collapse
No announcement yet.

CDECL - Variable Number of Optional Params

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

  • CDECL - Variable Number of Optional Params

    More C porting fun - I have a C DLL function that is declared:

    void CDECL ReadValues(hWindow as HWND, ... );

    According to the documentation, the function can accept ANY
    number of optional params after the required first param, as long
    as the list is terminated by a NULL.

    I realize I could just declare this in PB using CDECL with 10 or
    20 optional params to cover my anticipated usage of this function,
    but I thought I'd ask if there's a simpler method. For example,
    could I declare a single optional param but pass 10 params? If not,
    here's a suggestion for the wish list, adding a syntax similar to
    the "..." above for an unknown list of parameters.

    Thanks!


    ------------------
    Mark Newman
    Mark Newman

  • #2
    You could declare it to take up to 16 parameters, which is the parameter count limit of all versions of PowerBASIC.

    PowerBASIC does not support passing additional "undeclared" parameters such as you mention... to do so would be a guarantee to cause unanticipated problems for the unwary.



    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Hi Lance,

      Thanks for the info; I didn't know about the parameter count limit.
      16 params should be enough; if not I'll just do multiple calls.

      About the Unwary Parameter Passers , I could see where having
      a syntax like C's "..." for an unknown list of params could be
      abused. But would it not also provide more power for those who
      understand it? OTOH, I don't think this type of CDECL sytnax
      is used very much in the C world so not having it in PB isn't a
      big deal.


      ------------------
      Mark Newman
      Mark Newman

      Comment

      Working...
      X