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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!feeds.phibee-telecom.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Newcomers to comp.lang.ada: welcome and how did you end up here ? Date: Wed, 08 Oct 2014 10:15:38 +0100 Organization: A noiseless patient Spider Message-ID: References: <20141007101042.08f99687@atmarama.ddns.net> <1028866756434371637.714832laguest-archeia.com@nntp.aioe.org> <20141008092318.18ca2ecd@atmarama.ddns.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="865ecc8333c04b7dc8d5f87fc772110b"; logging-data="26777"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IuvsaQY3S/ZqcnWJJfkn+V9tAoLFCWAo=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:OWHJXhv2wgHHnAdQ1g5Cm1qL+LE= sha1:DIZyJftqEPMlIONTC2mv2H1gFhw= Xref: number.nntp.giganews.com comp.lang.ada:189516 Date: 2014-10-08T10:15:38+01:00 List-Id: Brian Drummond writes: > One hardware interface library in C (to the Aardvark I2C/SPI USB > interface from totalphase.com ) used a lot of macros for defining > constants. These were untranslated, appearing as comments in the Ada > package (apparently because they were untyped numbers). Apparently one should use g++ rather than gcc, because it makes a better job of it. GNAT GPL 2014 does translate (some) macros; it doesn't always get it right, eg #define M_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */ #define M_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */ #define MAXFLOAT 0x1.fffffep+127f // have to have _something_ besides the constants or no .ads gets // generated. extern float sinf(float); turns into pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package math_h is M_SQRT2 : constant := 1.41421356237309504880168872420969808; -- ./math.h:1 M_SQRT1_2 : constant := 8#.707106781186547524400844362104849039#; -- ./math.h:2 MAXFLOAT : constant := 16#1.fffffep+127f#; -- ./math.h:3 function sinf (arg1 : float) return float; -- ./math.h:7 pragma Import (CPP, sinf, "_Z4sinff"); end math_h; And I should have written extern "C" { extern float sinf(float); } which would have produced function sinf (arg1 : float) return float; -- math.h:8 pragma Import (C, sinf, "sinf");