Defining []NA call that requires a pointer to a pointer.
2 posts
• Page 1 of 1
Defining []NA call that requires a pointer to a pointer.
What's the best way to define this. I have a function that takes 2 arguments, see def. below.
int GetErrorMsg(int ErrorNo, char **errMsg)
I'm sure I can go the route of global alloc but is there a clean way to get this sting back?
int GetErrorMsg(int ErrorNo, char **errMsg)
I'm sure I can go the route of global alloc but is there a clean way to get this sting back?
(It's the little things that make the difference :-)
-
norbertjurkiewicz84 - Posts: 62
- Joined: Mon Nov 01, 2010 7:26 pm
Re: Defining []NA call that requires a pointer to a pointer.
Hi Norbert,
On MS Windows and a Dyalog 32-bit Unicode, I think the following will get you what you want.
⎕NA 'I4 thedll.dll|GetErrorMsg <0T P'
errMsg is a double indirect—as you mention, a pointer to a pointer.
To read errMsg, you’ll need to use the MEMCPY and STRNCPY techniques as shown in the ⎕NA documentation.
e.g.
'addrget' ⎕NA 'dyalog32|MEMCPY >P[] P U4'
addrget 1 ppaddr 4 ⍝ Where ppaddr is the char** errMsg from GetErrorMsg
The above gets a pointer to a character string so that we can pass it to STRNCPY:
'strget' ⎕NA 'dyalog32|STRNCPY* >0T1[] P U4'
Regards,
Vince
On MS Windows and a Dyalog 32-bit Unicode, I think the following will get you what you want.
⎕NA 'I4 thedll.dll|GetErrorMsg <0T P'
errMsg is a double indirect—as you mention, a pointer to a pointer.
To read errMsg, you’ll need to use the MEMCPY and STRNCPY techniques as shown in the ⎕NA documentation.
e.g.
'addrget' ⎕NA 'dyalog32|MEMCPY >P[] P U4'
addrget 1 ppaddr 4 ⍝ Where ppaddr is the char** errMsg from GetErrorMsg
The above gets a pointer to a character string so that we can pass it to STRNCPY:
'strget' ⎕NA 'dyalog32|STRNCPY* >0T1[] P U4'
Regards,
Vince
- Vince|Dyalog
- Posts: 413
- Joined: Wed Oct 01, 2008 9:39 am
2 posts
• Page 1 of 1
Return to Windows: GUI, COM/OLE/ActiveX
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group