From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1e7dd1f42fe2722e,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!Spring.edu.tw!news.nctu.edu.tw!feeder.seed.net.tw!netnews!not-for-mail From: "bubble" Newsgroups: comp.lang.ada Subject: how to declare a accss type in ada as C's generic pointer Date: Thu, 9 Dec 2004 14:29:58 +0800 Organization: HiNetNews Message-ID: NNTP-Posting-Host: 211.21.128.195 X-Trace: netnews.hinet.net 1102574439 962 211.21.128.195 (9 Dec 2004 06:40:39 GMT) X-Complaints-To: usenet@HiNetnews.hinet.net NNTP-Posting-Date: Thu, 9 Dec 2004 06:40:39 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Xref: g2news1.google.com comp.lang.ada:6872 Date: 2004-12-09T14:29:58+08:00 List-Id: dear all: I got a problem work with C's generic pointer(void *). in general case,I declare access type with convention pragma as C's pointer define. It work fine. my question is I don't know how to define a access type as C's generic pointer. now,I use System.address as C's generic point,is it correct? for example. in C,I got a C's .H file. enum message_type{singer_name=6,music_size=7,playTime=11} int querySongStatus(int message_type,char * message ,int max_message_length,int * message_length,void * Num); in Ada.I rewrite it and import it to ada. such as package work is pragma Liner_Options("-lmymusic32"); type message_type is (singer_name,music_size,play_time); subtype myString is string(1..300); type mystring_access is access all mystring; type integer_access is access all integer; function query_Song_Status( msg_type:message_type; message:mystring; max_message_length:integer; message_length:integer_access; Num:System.address); pragma Conversion(C,mystring); pragma COnversion(C,integer_access); pragma import(Stdcall,query_Song_Status,"querySongStatus"); private for message_Type use ( singer_name=>6; music_size=>7; playTime=>11); end work; in C,if I want to query singer name then char * name = (char *)malloc (sizeof(char) * 300); int length=0; //I must pass a char pointer to querySongStatus.. querySongStatus(singer_name,name,300,&length,null); else if I want to query song's disk size then int diskByte=0; //I must pass a integer pointer to last parameter querySongStatus(music_size,null,0,null,&diskByte); else if I want to query a song's play time then float totalTime; //I must pass float pointer to last parameter querySongStatus(playTime,null,0,0,&totalTime); the last parameter is generic pointer, the C's function will cast the generic pointer to another type pointer according to what the first parameter is? in Ada. I don't know how to declare the access type correct? can anybody tell me how to do? thanks.