5

I want to return from IDL an array of interfaces. I try this:

interface ISecurityPolicy : IDispatch{
[id(6)]          HRESULT GetPolicyList([out, ref, retval] SAFEARRAY(IEntityPolicy*)* result);
}

I get this warning(in VS 2010): Warning 1 warning MIDL2456: SAFEARRAY(interface pointer) doesn't work using midl generated proxy : [ Parameter 'result' of Procedure 'GetPolicyList' ( Interface 'ISecurityPolicy' ) ]

Is this a bogus warning as http://social.msdn.microsoft.com/Forums/en-US/vcmfcatl/thread/84a632a9-4e29-4a95-8da7-f7aedb650339 might suggest ?

3
  • Drop the [ref] attribute, it doesn't make much sense. Commented Sep 8, 2011 at 13:12
  • I'm afraid that I still get the warning for that too. On the other side, things work, you just have to adjust the return type as SAFEARRAY(IUnknown*)* to make things easier Commented Sep 8, 2011 at 17:20
  • It could be a better idea for me to use a collection implementation for the same propose though. It would be much more clear, only more work to do :-) Commented Sep 9, 2011 at 8:00

1 Answer 1

2

Declaring this as:

interface ISecurityPolicy : IDispatch{
[id(6)]          HRESULT GetPolicyList([out, ref, retval] SAFEARRAY(IUnknown*)* result);
}

simplifies things a little for implementation of the interface. It could still be a better idea though instead of returning an array of interfaces to the caller to return it an iterator over the "collection".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.