question

ReneGerlach-5047 avatar image
0 Votes"
ReneGerlach-5047 asked RLWA32-6355 edited

#import "tlbname" raw_interfaces_only raw_dispinterfaces - did not generate HRESULT low-level wrapper functions

Hi @ll,

I've some trouble to generate native functions without error handling from a tlb.
I need this to check in a project the functions which will throw an exception and may not correct handled.
To find this, I tried to disable the generation of these functions and get a compile error on these.

But disable generation of error handling function did not work:
Sample:

 #import "tlbname" raw_interfaces_only raw_dispinterfaces

did not generate the low-level wrapper functions.
I try to get only the following:

 HRESULT get_VariantGuid ( BSTR* variantGuid );

But I get:

 _bstr_t get_VariantGuid ( );

If I remove the raw_interfaces_only I get both, but this is not what I want. I need only the HRESULT function, as described in the docu:
Suppresses the generation of error-handling wrapper functions, and property declarations that use those wrapper functions.

Also I tried the high_property_prefixes to rename the error handling properties, but this only rename the methods not the properties.
Sample:

 #import "tlbname" high_property_prefixes("HighGet", "HighUsePut", "HighUsePutRef") 
     __declspec(property(get=HighGetVariantGuid))
     _bstr_t **VariantGuid**; // <<-- this should also have the prefix "HighGet"
        
     _bstr_t HighGetVariantGuid ( );

Any ideas what can be wrong or how to solve this?
looks like an #import issue?


Edit - Upgrade to 16.10.2

After upgrade to 16.10.2 it didn't compile anymore with
"raw_interfaces_only raw_dispinterfaces"
sample:

 1>tlbname.tli(13,42): error C2039: 'get_ApplicationEnvironment': is not a member of 'tlbnamespace::IApplicationInfoProvider'
 1>tlbname.tlh(594): message : see declaration of 'tlbnamespace::IApplicationInfoProvider'

the .tlh looks like:

      // Created by Microsoft (R) C/C++ Compiler Version 14.29.30038.1 (5db89de9).
 ....`
 `   IApplicationInfoProvider : IDispatch
     {
    
       //
         // Wrapper methods
         //
        
         // Methods:
        _bstr_t RawGetApplicationEnvironment ( );
        _bstr_t RawGetApplicationRelease ( );
        _bstr_t RawGetApplicationReleaseExt ( );
        struct _StringMap * RawGetApplicationSettings ( );
        struct IFrameInfo * RawGetFrameInfo ( );
     };

How to test:
Just create a new ATL-DLL project, add the #import

 #import "tlbname" raw_interfaces_only raw_dispinterfaces \
                        raw_property_prefixes("RawGet", "RawUsePut", "RawUsePutRef")    \
                        raw_method_prefix( "RawMethod" ) \
                        high_property_prefixes("HighGet", "HighUsePut", "HighUsePutRef")    \
                        high_method_prefix ("HighMethod")



c++
· 14
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Which version of VS are you using?

0 Votes 0 ·

I could not duplicate the issue using VS2019 16.10.2.

0 Votes 0 ·

I'm using 16.9.4

0 Votes 0 ·

Maybe you should update to VS2019 to 16.10.2 and try again.

Or share a minimal demo that reproduces the problem so that we can build it on our systems to see if the issue manifests.

0 Votes 0 ·
Show more comments

Remove all #import attributes except for raw_interfaces_only. Then what happens?

0 Votes 0 ·

After removing compiling possible,
But always only the high level wrapper instead of low level function will be generate:

 #import "tlbname" raw_interfaces_only raw_dispinterfaces
 IApplicationInfo : IDispatch
 {
     //
     // Wrapper methods
     //
    
     // Methods:
    _bstr_t get_ApplicationEnvironment ( );
    void put_ApplicationEnvironment (
         /*[in]*/ _bstr_t _arg1 );
0 Votes 0 ·

Also remove raw_dispinterfaces.

0 Votes 0 ·
Show more comments

1 Answer

RLWA32-6355 avatar image
0 Votes"
RLWA32-6355 answered RLWA32-6355 edited
  dispinterface IApplicationInfoProvider {
      properties:
      methods:
          [id(0x00000001), propget]
          BSTR ApplicationEnvironment();

That's what I suspected. This is the reason why #import does not create a header file that includes the low-level functions that you want. Your expectations are incorrect for a dispinterface. When a dispinterface is used its properties and methods can only be referenced through the methods of the IDispatch interface (e.g., IDispatch::Invoke). There are no low-level methods for #import to include in a generated header when using raw_interfaces_only because they don't exist. Your expectations are inline with a dual interface that has been declared as inheriting from IDispatch in the IDL.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.