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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c6e88c9c6862d6b4,start X-Google-Attributes: gid103376,public From: how to read C extern variables from Ada? Subject: nabbasi@pacbell.net Date: 1999/02/28 Message-ID: <7bbd3c$gf7@drn.newsguy.com>#1/1 X-Deja-AN: 449507594 Organization: Newsguy News Service [http://www.newsguy.com] Newsgroups: comp.lang.ada Date: 1999-02-28T00:00:00+00:00 List-Id: Hello, It is easy to interface to C from Ada. But one problem that I could not see mentioned in annex B, is how to get access to 'extern' variables. For example, I can call getopt() from Ada. But the problem is that getopt() sets values into an extern variables that are defined is C header files, and so can be read from C client programs after the call to getopt() returns. -------------------- SYNOPSIS #include int getopt(int argc, char * const argv[], const char *optstring); extern char *optarg; extern int optind, opterr, optopt; ----------------------- So, in the above, after I call getopt(), I need a way to 'read' optarg. There is no C API to read optarg. So, How to do this in Ada?? thanks, Nasser ps. offcourse I could write a small C stub that the Ada program calls, and then it calls getopt(), and this C stub could read the extern variables. and I define an API to this C stub function to return these variables via function call. But I wanted to see if I can do the whole thing in 100% pure Ada :), it also makes the Makefile simpler. This is GNAT 3.11p.