comp.lang.ada
 help / color / mirror / Atom feed
* nabbasi@pacbell.net
@ 1999-02-28  0:00 how to read C extern variables from Ada?
  1999-02-28  0:00 ` nabbasi@pacbell.net Matthew Heaney
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: how to read C extern variables from Ada? @ 1999-02-28  0:00 UTC (permalink / raw)


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 <unistd.h>

    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.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-03-02  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-28  0:00 nabbasi@pacbell.net how to read C extern variables from Ada?
1999-02-28  0:00 ` nabbasi@pacbell.net Matthew Heaney
1999-02-28  0:00 ` how to read C extern variables from Ada? David C. Hoos, Sr.
1999-03-02  0:00 ` nabbasi@pacbell.net Stephen Leake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox