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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d71460587da14d5b,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-30 13:03:19 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!wn12feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!rwcrnsc53.POSTED!not-for-mail From: Freejack Subject: Importing C structs? Newsgroups: comp.lang.ada Message-ID: User-Agent: Pan/0.11.4 (Unix) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Comment-To: ALL NNTP-Posting-Host: 12.245.85.50 X-Complaints-To: abuse@comcast.net X-Trace: rwcrnsc53 1059595398 12.245.85.50 (Wed, 30 Jul 2003 20:03:18 GMT) NNTP-Posting-Date: Wed, 30 Jul 2003 20:03:18 GMT Organization: Comcast Online Date: Wed, 30 Jul 2003 20:03:18 GMT Xref: archiver1.google.com comp.lang.ada:41040 Date: 2003-07-30T20:03:18+00:00 List-Id: I'm finally starting to get an idea(at least I think I am.) on handling interfacing to C. However, I'm fuzzy on importing C structs. In a nutshell...here is the function I'm attempting to import... DB * dbopen(const char *file, int flags, int mode, DBTYPE type, const void *openinfo); Where "int mode" corresponds to the C "open" declaration and DBTYPE is a C struct. I'm using the dbopen man page for the Sleepycat Berkely DB. Now I'm using pragma Import( C, dbopen ); And then casting everything as either a C.integer or a character pointer. It compiles this way, but it sucks as a way to do it. Specifically, would I cast DBTYPE as a seperate record type, and then provide a seperate function to translate each item into the type expected by the C struct? Or can import the DBTYPE struct whole hog into my Ada specification? Note, you'll need the SleepyCat Berkely DB header file db.h in order to see what I'm referring to. I've gained some skills in working strictly with the Ada environment. But Interfacing with C is gonna take me a little while longer to learn. Thanks for any pointers. Freejack