通过 C++数组到 Ada95
我正在尝试将一个无符号整数数组从 C++ 传递到 Ada。 Ada Lovelace 教程指出,Ada 数组对应于 C++ 中指向数组第一个元素的指针。
这就是我正在尝试做的事情。
C++
unsigned int buffer[bufferSize];
...
unsigned int* getBuffer() {
return buffer;
}
Ada 但
pragma Import (C, C_Get_Buffer, "getBuffer");
...
function C_Get_Buffer returns System.Address;
...
Buffer : array (1 .. Buffer_Size) of Interfaces.C.Unsigned;
...
Buffer'Address := C_Get_Buffer;
我发现 Buffer'Address 无法分配。将数组从 C 传递到 Ada 的正确方法是什么?
谢谢!
I'm trying to pass an array of unsigned integers from C++ to Ada. The Ada Lovelace tutorial states that an Ada array corresponds to a pointer to the first element of an array in C++.
Here is what I'm trying to do.
C++
unsigned int buffer[bufferSize];
...
unsigned int* getBuffer() {
return buffer;
}
Ada
pragma Import (C, C_Get_Buffer, "getBuffer");
...
function C_Get_Buffer returns System.Address;
...
Buffer : array (1 .. Buffer_Size) of Interfaces.C.Unsigned;
...
Buffer'Address := C_Get_Buffer;
I'm finding that Buffer'Address cannot be assigned however. What is the correct way to go about passing an array from C to Ada?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这将按照您的要求进行(我没有为
Buffer_Size
烦恼):但是,这可能适合作为实现相同目标的较短方法:
This will do as you ask (I didn’t bother with
Buffer_Size
):However, this might be appropriate as a shorter way of achieving the same thing: