comp.lang.ada
 help / color / mirror / Atom feed
* Binding to functions having reference parameter
@ 2002-05-08 14:40 Antonio L�pez
  2002-05-08 15:19 ` Stephen Leake
  0 siblings, 1 reply; 3+ messages in thread
From: Antonio L�pez @ 2002-05-08 14:40 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1060 bytes --]

I am doing a binding to a Dll Using Win32 binding and I have a problem with
functions having reference parameters (an C array).

�How must I declare those parameters? (ada functions doesn't allow out
parameters)

One example:

Dll fucntion is declared as :

_API_EXTERN AiInt16 _API_DLL_FUNC ApiCmdBite (AiUInt8 bModule, AiUInt8 biu,
AiUInt8 sc, AiUInt8 bite_status[]);

And I declare:

subtype UCHAR is Interfaces.C.unsigned_char;

type UCHAR_Array2 is array (0 .. 1) of aliased UCHAR;

function ApiCmdBite ( bModule : My_Win32.UCHAR; biu : My_Win32.UCHAR; sc :
My_Win32.UCHAR;

bite_status : My_Win32.UCHAR_Array2 )

return My_Win32.SHORT;

However I get a warning: "bite_status" is never assigned a value, calling
the fucntion.

Obvius It needs to be done otherwise! Could you enlight me please?

I have tried to pass the parameter as bite_status :
Interfaces.C.unsigned_char'Address but I get the error: attribute "Address"
may not be used in a subtype mark

I should be able to use for example: 'bite_status(0) := 1;' or 'if
(bite_status(1) == 2)'






^ permalink raw reply	[flat|nested] 3+ messages in thread
* RE: Binding to functions having reference parameter
@ 2002-05-08 18:39 Beard, Frank [Contractor]
  0 siblings, 0 replies; 3+ messages in thread
From: Beard, Frank [Contractor] @ 2002-05-08 18:39 UTC (permalink / raw)


function ApiCmdBite ( bModule     : My_Win32.UCHAR;
                      biu         : My_Win32.UCHAR;
                      sc          : My_Win32.UCHAR;
                      bite_status : access My_Win32.UCHAR_Array2 );

return My_Win32.SHORT;

Then, the variable you have declared to pass to it needs to be
something like:

  new_bite_status : aliased My_Win32.UCHAR_Array2;

So, that when you call it, it will look something like

  return_code := ApiCmdBite ( bModule     => ???,
                              biu         => ???,
                              sc           => ???,
                              bite_status => new_bite_status'access);

Frank

-----Original Message-----
From: Antonio López [mailto:alm@gtd.es.REMOVE]
Sent: Wednesday, May 08, 2002 10:40 AM
To: comp.lang.ada@ada.eu.org
Subject: Binding to functions having reference parameter


I am doing a binding to a Dll Using Win32 binding and I have a problem with
functions having reference parameters (an C array).

¿How must I declare those parameters? (ada functions doesn't allow out
parameters)

One example:

Dll fucntion is declared as :

_API_EXTERN AiInt16 _API_DLL_FUNC ApiCmdBite (AiUInt8 bModule, AiUInt8 biu,
AiUInt8 sc, AiUInt8 bite_status[]);

And I declare:

subtype UCHAR is Interfaces.C.unsigned_char;

type UCHAR_Array2 is array (0 .. 1) of aliased UCHAR;

function ApiCmdBite ( bModule : My_Win32.UCHAR; biu : My_Win32.UCHAR; sc :
My_Win32.UCHAR;

bite_status : My_Win32.UCHAR_Array2 )

return My_Win32.SHORT;

However I get a warning: "bite_status" is never assigned a value, calling
the fucntion.

Obvius It needs to be done otherwise! Could you enlight me please?

I have tried to pass the parameter as bite_status :
Interfaces.C.unsigned_char'Address but I get the error: attribute "Address"
may not be used in a subtype mark

I should be able to use for example: 'bite_status(0) := 1;' or 'if
(bite_status(1) == 2)'



_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/mailman/listinfo/comp.lang.ada



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-05-08 18:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-08 14:40 Binding to functions having reference parameter Antonio L�pez
2002-05-08 15:19 ` Stephen Leake
  -- strict thread matches above, loose matches on Subject: below --
2002-05-08 18:39 Beard, Frank [Contractor]

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox