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: a07f3367d7,1f8050edb14e8329 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news3.google.com!feeder.news-service.com!188.40.43.213.MISMATCH!feeder.eternal-september.org!eternal-september.org!not-for-mail From: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: Interfacing to C Date: Thu, 24 Dec 2009 18:07:52 -0800 Organization: None to speak of Message-ID: References: <56284e56-6ac5-427c-8e4f-8a0750527088@z41g2000yqz.googlegroups.com> <53faf11a-df58-45ca-b287-5e1901fcf5a4@c34g2000yqn.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.eternal-september.org U2FsdGVkX18ysclAtDMeM+AWCksrz4SmoSKOPlWvZMXF+Uvp2HYiocdXb5a4YqKIw/na5LFK96dRMJH6d9fRa3hn7Rvdg4pVvfHfj+8/tdmV+jkG1v/hjru9SjSSqCWq1vderVokTOQ= X-Complaints-To: abuse@eternal-september.org NNTP-Posting-Date: Fri, 25 Dec 2009 02:10:39 +0000 (UTC) X-Auth-Sender: U2FsdGVkX19N1oDeKx3KlR7NtFE5iWIu Cancel-Lock: sha1:c5F5Y9vSYT7C2Gd4cv4Ft+TjvRY= sha1:TdT513FxjyUIQuDmm8ey7/ZlJ98= User-Agent: Gnus/5.101 (Gnus v5.10.10) Emacs/21.4 (gnu/linux) Xref: g2news1.google.com comp.lang.ada:8520 Date: 2009-12-24T18:07:52-08:00 List-Id: "Hibou57 (Yannick Duchêne)" writes: > On 24 déc, 10:46, "RasikaSriniva...@gmail.com" > wrote: >> I am building an interface to a C library. This library uses structs >> like the following: >> >> typedef struct { >>     x : int ; >>     y : int }  MyStruct .... (The correct syntax is: typedef struct { int x; int y; } MyStruct; ) >> While passing variables of this type to functions, the convention in C >> is to pass by value (best of my knowledge). Yes. In fact, C doesn't have pass by reference as a language feature; *all* function arguments are passed by value. For structs, it's very common in C to do the equivalent of pass-by-reference, by explicitly passing the address of the struct object. This is partly because very old versions of C didn't support struct parameters. I find it a bit odd that Ada imposes a pass-by-pointer convention for C structs. (No, C arrays aren't passed by reference. C array expressions, in most contexts, are implicitly converted to pointers; the resulting pointer can be passed by value.) [...] -- 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"