Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Can't seem to compile a SAFEARRAY member for my interface

Can't seem to compile a SAFEARRAY member for my interface

Scheduled Pinned Locked Moved ATL / WTL / STL
csharpc++visual-studiocomdata-structures
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Todd Jeffreys
    wrote on last edited by
    #1

    I am creating a COM interface to some library I have and I am trying to make an Initialize function that takes as it argument a SAFEARRAY of BSTR's. I am using VS .NET 2000 and the ATL wizard. I added an object and am manually adding the entry for the function since SAFEARRAY is not an option for the auto-add member wizard. Here is what I have so far: __interface IiidApplication : IDispatch { [id(1),helpstring("method Initialize")] HRESULT Initialize([in] SAFEARRAY(BSTR) *par); } Then later I have the function defined as STDMETHOD(Initialize)(LPSAFEARRAY pvar); The IDL will not compile however. I get errors on the Initialize line complaining about an extra ) and missing ) and ; before *. If I remove the (BSTR) and just leave it as SAFEARRAY *par, it will not link because it complains about not knowing the size of the array or similar. All the MS doc's seem to have the format as SAFEARRAY(your datatype) but it doesn't seem to be working for me. Any suggestions?

    P V V 3 Replies Last reply
    0
    • T Todd Jeffreys

      I am creating a COM interface to some library I have and I am trying to make an Initialize function that takes as it argument a SAFEARRAY of BSTR's. I am using VS .NET 2000 and the ATL wizard. I added an object and am manually adding the entry for the function since SAFEARRAY is not an option for the auto-add member wizard. Here is what I have so far: __interface IiidApplication : IDispatch { [id(1),helpstring("method Initialize")] HRESULT Initialize([in] SAFEARRAY(BSTR) *par); } Then later I have the function defined as STDMETHOD(Initialize)(LPSAFEARRAY pvar); The IDL will not compile however. I get errors on the Initialize line complaining about an extra ) and missing ) and ; before *. If I remove the (BSTR) and just leave it as SAFEARRAY *par, it will not link because it complains about not knowing the size of the array or similar. All the MS doc's seem to have the format as SAFEARRAY(your datatype) but it doesn't seem to be working for me. Any suggestions?

      P Offline
      P Offline
      pain
      wrote on last edited by
      #2

      If i were you , i did better choose to use VARIANT type in the parameter passing and cast it to safe array later This will make the COM more compatible with other languages

      1 Reply Last reply
      0
      • T Todd Jeffreys

        I am creating a COM interface to some library I have and I am trying to make an Initialize function that takes as it argument a SAFEARRAY of BSTR's. I am using VS .NET 2000 and the ATL wizard. I added an object and am manually adding the entry for the function since SAFEARRAY is not an option for the auto-add member wizard. Here is what I have so far: __interface IiidApplication : IDispatch { [id(1),helpstring("method Initialize")] HRESULT Initialize([in] SAFEARRAY(BSTR) *par); } Then later I have the function defined as STDMETHOD(Initialize)(LPSAFEARRAY pvar); The IDL will not compile however. I get errors on the Initialize line complaining about an extra ) and missing ) and ; before *. If I remove the (BSTR) and just leave it as SAFEARRAY *par, it will not link because it complains about not knowing the size of the array or similar. All the MS doc's seem to have the format as SAFEARRAY(your datatype) but it doesn't seem to be working for me. Any suggestions?

        V Offline
        V Offline
        Vi2
        wrote on last edited by
        #3

        The satype attribute should be used in your case: [id(1),helpstring("...")] HRESULT Initialize([in,satype(BSTR)] SAFEARRAY* *par); With best wishes, Vita

        1 Reply Last reply
        0
        • T Todd Jeffreys

          I am creating a COM interface to some library I have and I am trying to make an Initialize function that takes as it argument a SAFEARRAY of BSTR's. I am using VS .NET 2000 and the ATL wizard. I added an object and am manually adding the entry for the function since SAFEARRAY is not an option for the auto-add member wizard. Here is what I have so far: __interface IiidApplication : IDispatch { [id(1),helpstring("method Initialize")] HRESULT Initialize([in] SAFEARRAY(BSTR) *par); } Then later I have the function defined as STDMETHOD(Initialize)(LPSAFEARRAY pvar); The IDL will not compile however. I get errors on the Initialize line complaining about an extra ) and missing ) and ; before *. If I remove the (BSTR) and just leave it as SAFEARRAY *par, it will not link because it complains about not knowing the size of the array or similar. All the MS doc's seem to have the format as SAFEARRAY(your datatype) but it doesn't seem to be working for me. Any suggestions?

          V Offline
          V Offline
          vprashu
          wrote on last edited by
          #4

          This is one of the interfaces in my project and it compiles without any problem in both Vc 6.0 and VS 2003. I have'nt tried VS.Net 2002 but it should work. The only difference is that mine is a IUnknown interface interface IMyInterface : IUnknown { ........ HRESULT MyFunction( [in] SAFEARRAY(BSTR)* inputArray); }; FYI, The implementation of this method in ur .h must look like STDMETHOD(MyFunction)(SAFEARRAY** inputArray); Hope this helps. prashu

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups