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-Thread: 103376,74bc23dcb20218db X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!newsfeed.straub-nv.de!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: How to access this package written in C? Date: Thu, 22 Apr 2010 14:12:31 -0700 Organization: None to speak of Message-ID: References: <4e9d2aaf-c0a6-4798-b838-8f5b7c4a39d1@k33g2000yqc.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Thu, 22 Apr 2010 21:12:39 +0000 (UTC) Injection-Info: news.eternal-september.org; posting-host="9nFTuw1iclElqUG5+//YDQ"; logging-data="21791"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18kozkT+Pc8wm5ze8flXrfx" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:aXxSkyPmHKKYz1DY1DtChregSaI= sha1:V4Ug74UXdPzkJ6eandel6ouORy4= Xref: g2news1.google.com comp.lang.ada:10143 Date: 2010-04-22T14:12:31-07:00 List-Id: resander writes: > I am working on software that manipulates SQL databases via a GUI. It > is written in C or C++ without classes and compiled on Linux. Would > also want it to run on Windows eventually. This software has > essentially one entry procedure: > > int guidb ( int appno , int recaddress ); // in C > > which returns an outcome as an int, takes an int appno which specifies > application and an address of a record in recaddress. The latter is > used for passing the memory address of any recordtype variable and is > cast to a byte address inside guidb. [...] As others have mentioned, this is bad C. There is no guarantee that an int can hold the value of an address, and there are common systems (including Linux systems) where it can't. Worse, you're not likely to get a warning if you convert a pointer to int, even if there's a loss of information. The right type for this parameter is void* (which is roughly analogous to Ada's System.Address). -- Keith Thompson (The_Other_Keith) kst-u@mib.org Nokia "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"