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: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!news-xxxfer.readnews.com!news-out.readnews.com!s09-03.readnews.com!not-for-mail X-Trace: DXC=57M=5PhmJe]77A>Rd>\gYW[3OhcoN[H0PX44`8^\]>7Z25[I[UfBM:U User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Unchecked_Union record inside an other record - trouble References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <53e52322$0$32389$862e30e2@ngroups.net> NNTP-Posting-Host: 52f0112f.ngroups.net Xref: news.eternal-september.org comp.lang.ada:21569 Date: 2014-08-08T21:21:06+02:00 List-Id: You shall not try to write interface code by hand you shall use the compiler gcc -c -fdump-ada-spec see GNAT Users guide. Since humans makes a heap load of errors and erronous asumptions when they try to translate the contents of a .h file to an .ads file, the compiler does a much better job. /Per On 08.08.2014 17:36, Victor Porton wrote: > I am trying to interface my program with a C library. > > The below program does not compile: > > main.adb:19:14: unconstrained subtype in component declaration > > If this does not work, what should I do to interface a union inside a struct > in a C library? > > -- main.adb > with Interfaces.C; use Interfaces.C; > > procedure Main is > > type Kind is (First, Second); > > type T(K: Kind) is > record > case K is > when First => I: int; > when Second => C: char; > end case; > end record > with Unchecked_Union, Convention=>C; > > type T2 is > record > Z: int; > Ob: T; > end record > with Convention=>C; > > begin > null; > end; >