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,6413b417b806eb28 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Accessing C macro constants from Ada95 Date: 1999/04/12 Message-ID: <7erp6b$o3f$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 465314963 References: <7eg43i$d3b$1@nnrp1.dejanews.com> <370CC730.4C6112DB@utech.net> <370D7007.2D3AD58B@rocketmail.com> <7el9so$geb@drn.newsguy.com> <7elrg5$egk2@ftp.kvaerner.com> <7emjk8$rp3@drn.newsguy.com> <7ep6uj$o97$1@nnrp1.dejanews.com> <7eqoj2$r27$1@pegasus.csx.cam.ac.uk> X-Http-Proxy: 1.0 x11.dejanews.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Mon Apr 12 03:27:15 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-04-12T00:00:00+00:00 List-Id: In article <7eqoj2$r27$1@pegasus.csx.cam.ac.uk>, mgk25@cl.cam.ac.uk (Markus Kuhn) wrote: > Ada does indeed have nice facilities to access functions > and variables in C object files, but what has been > completely forgotten is that > under C, traditionally a very significant part of the API > comes in the form of numeric macro constants defined in > *.h files. This was most certainly not "forgotten" ... > What would be necessary is that every > Ada95 compiler that implements a C interface contains a complete > ISO C macro preprocessor. An import pragma would then allow to extract > an arbitrary numeric constant from any specifyable *.h file and > could then be used as an Ada constant. This is so impractical that I can't tell if you are really serious. In any case you do a good job of indicating why there is no automatic feature for importing such constants! > And Ada95 does not provide a portable way to get at > these. You mean apart from defining them, copying the constants (no different in principle from copying the parameters when you pragma Import something ....) > Ada programmers should not have to write buggy and > dangerous Perl hacks again and again to get access to the > constants in C header files. I don't think they should do this even once, I certainly never have, and have accessed such constants many times. Basically, when importing functions or constants, we have two ways of doing things. We either look at the header, and manually acquire the functions and their parameters, and any constant values needed, and write the necessary declarations in our Ada program manually. Or we use a program like c2ada, or the SGI binding generator that reads a header and automaticlly extracts this information. I do not see the big deal here! If you have a situation where the constants can change and you do not want to have to modify the Ada accordingly, then it is easy enough (again manually or automatically) to write simple C functions that "cloak" the constants. I must say I have never found this to be a significant difficulty. On the other hand, trying to pursue the language extension suggestion that Markus makes sounds deadly to me. Just imagine the amount of material that would be required for a stand alone definition of exactly what this Import pragma would do, UGH! -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own