Re: C chars_ptr STORAGE_ERROR in Imported function
- From: anon@xxxxxxxx (anon)
- Date: Fri, 22 Aug 2008 18:48:44 GMT
Because Char_Prt in "Interfaces.C.Strings" is a private Ada type that
C function does not understand. You need to use "Interfaces.C.Pointer"
package to build a C Char_Ptr pointer package. And use those functions,
etc.
A possibility that most teachers may frown about, but it does work is to
switch the Ada pointers to "System.Address" and pass to the C functions..
Check out the "Interfaces.C.Extensions.ads" to see how the "void" and
"void *" are handled, if the teachers dislike the idea.
In <g8ltqo$7ir$1@xxxxxxxxxxxxxxx>, Kim Rostgaard Christensen <krc@xxxxxxxxxx> writes:
Hello there
I am in progress of binding the pcap c library to ada, it is a part of a
school project. And for that i need a funtion that modifies a parameter
to a function like so:
char *pcap_lookupdev(char *);
I have figured out this much:
function pcap_lookupdev(errbuff : Interfaces.C.Strings.Chars_Ptr)
return Interfaces.C.Strings.Chars_Ptr;
pragma Import (C, pcap_lookupdev, "pcap_lookupdev");
This works in the sense that running it as root returns the device
found, but when I run it as normal user I get
raised STORAGE_ERROR : stack overflow (or erroneous memory access)
Do I need to declare the buffer and then then pass its c pointer to the
function?
It is declared like this in a c example:
char errbuf[PCAP_ERRBUF_SIZE];
Best
Kim Rostgaard Christensen
.
- Follow-Ups:
- Re: C chars_ptr STORAGE_ERROR in Imported function
- From: Niklas Holsti
- Re: C chars_ptr STORAGE_ERROR in Imported function
- References:
- C chars_ptr STORAGE_ERROR in Imported function
- From: Kim Rostgaard Christensen
- C chars_ptr STORAGE_ERROR in Imported function
- Prev by Date: Re: Ada courses
- Next by Date: Re: Ada courses
- Previous by thread: Re: C chars_ptr STORAGE_ERROR in Imported function
- Next by thread: Re: C chars_ptr STORAGE_ERROR in Imported function
- Index(es):
Relevant Pages
|