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,693c0db9fd624c1d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-29 13:17:02 PST Path: news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: C Integers -> Booleans: shortcut? Date: Mon, 29 Sep 2003 15:19:07 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <7bEdb.1944$QH3.1487@newsfep4-winn.server.ntli.net> X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-Complaints-To: abuse@supernews.com Xref: news1.google.com comp.lang.ada:209 Date: 2003-09-29T15:19:07-05:00 List-Id: "Simon Wright" wrote in message news:x7vpthkrg0h.fsf@smaug.pushface.org... > chris writes: > > > Can you (in general) import a function taking/returning a C integer > > and treat it like a boolean for import? Let the compiler deal with > > the difference? > > With GNAT you would say > > type C_Boolean is new Boolean; > pragma Convention (C, C_Boolean); > > with the meaning that 0 => False, anything else => True. > > For other compilers I would think you'd be better off specifying > Interfaces.C.int and comparing to 0. Janus/Ada automatically converts Boolean to the C equivalent for calls. We used it in our early Windows bindings - made things quite a bit clearer. But the point is that it isn't standard, so if you want your code to work on other compilers, don't do that. Claw doesn't use that, for instance. Randy.