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,5a84d5077c54a29d X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada array vs C pointer (call by reference) References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <3de9k.228623$yE1.227772@attbi_s21> NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1214607295 12.201.97.213 (Fri, 27 Jun 2008 22:54:55 GMT) NNTP-Posting-Date: Fri, 27 Jun 2008 22:54:55 GMT Organization: AT&T ASP.att.net Date: Fri, 27 Jun 2008 22:54:55 GMT Xref: g2news1.google.com comp.lang.ada:928 Date: 2008-06-27T22:54:55+00:00 List-Id: Adrian Hoe wrote: > > Can I use Float instead of Interfaces.C.C_Float? You can use anything you want: Boolean, Duration, a task type, ... But if you want to be sure it will work, you'll use Interfaces.C.C_Float. > Why use Interfaces.C.Int, Interfaces.C.C_Float since they are all new > declaration of Ada types. > > I know it is for readability and maintainability but the question is > logical as the declaration in Interfaces.C is just merely creating a > new Ada type with a new name, unless there is pragma Convention > statement after every such declaration in Interfaces.C. I suggest you read ARM B.3. There you'll find, "Each of the types declared in Interfaces.C is C-compatible." > Wouldn't it be better to write as such? > > type C_Data is array (Positive range <>) of Float; > pragma Convention (C, C_Data); Not if you want to be sure it will work. > Is PWM_Data passed as pointer to pwmRead? B.3 also contains, "An Ada parameter of an array type with component type T, of any mode, is passed as a t* argument to a C function, where t is the C type corresponding to the Ada type T." -- Jeff Carter "Hello! Smelly English K...niggets." Monty Python & the Holy Grail 08