0

Please forgive the potentially poorly worded question, but I'm unsure of how to search for this information as I have no concise way to describe it. I was looking through some APIs and found some interesting syntax which did not seem to mean what I thought.

virtual void CreateThing(HANDLE(*pParameterName)[3]);

Now I know this API (details below) wants me to create 3 handles and give them back, e.g.

pParameterName[0] = CreateHandle()
pParameterName[1] = CreateHandle()
pParameterName[2] = CreateHandle()

However I am having trouble grasping the meaning of the parameter syntax. Is this simply an array of 3 pointers to handles? I suspected so, when I try to use this more familiar syntax to override the function, it does not compile, indicating that they are not the same

virtual void CreateThing(HANDLE* pParameterName[3]);

In other words What is the difference between the two declarations?

P.S.

The real API is CreateSwapTextureSet in OpenVR for Drivers

virtual void CreateSwapTextureSet( uint32_t unPid, uint32_t unFormat, uint32_t unWidth, uint32_t unHeight, vr::SharedTextureHandle_t( *pSharedTextureHandles )[ 3 ] ) {}
Ben
  • 2,867
  • 2
  • 22
  • 32
  • 1
    This is probably closeable as a duplicate, but not as "must have a specific problem and show a minimal example". I see no edits to the question. I'm confused. – Millie Smith Mar 05 '17 at 07:54
  • I actually don't see any links that are extremely clear on this, though I haven't read much of @JamesRoot's link. From my brief tests (I always have to check this syntax myself), you can only pass a pointer to a stack array of size 3 of HANDLEs. No dynamically allocated array will do and no stack array of any other size will do. This gives compile-time validation of the array size and documents that they always need 3 inside the function itself. Edit: voted to close with Root's link. – Millie Smith Mar 05 '17 at 08:01
  • I agree @JamesRoot, I think the answer to my question is "It is not an array of pointers, it is a pointer to an array of size 3". I will accept the duplicate closure. Thanks! Millie thanks for verifying before voting to close – Ben Mar 05 '17 at 08:06
  • @Ben The syntax is clearly explained in the 3rd answer. – πάντα ῥεῖ Mar 05 '17 at 08:06

0 Answers0