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,d3b2e17058959a22 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-03-23 19:50:26 PST Path: nntp.gmd.de!news.rwth-aachen.de!news.rhrz.uni-bonn.de!news.uni-stuttgart.de!rz.uni-karlsruhe.de!xlink.net!howland.reston.ans.net!gatech!purdue!haven.umd.edu!ames!newsfeed.gsfc.nasa.gov!news!sal714 From: sal714@rs710.gsfc.nasa.gov (Stephen A. Leake) Newsgroups: comp.lang.ada Subject: Re: C++ to Ada95, help please Date: 23 Mar 1995 18:01:33 GMT Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Message-ID: References: <3kjd2m$d3t@jerry.rb.icl.co.uk> NNTP-Posting-Host: rs710.gsfc.nasa.gov In-reply-to: skj@rb.icl.co.uk's message of 20 Mar 1995 08:06:46 -0000 Date: 1995-03-23T18:01:33+00:00 List-Id: In article <3kjd2m$d3t@jerry.rb.icl.co.uk> skj@rb.icl.co.uk (Simon Johnston) writes: In article <3kjd2m$d3t@jerry.rb.icl.co.uk> skj@rb.icl.co.uk (Simon Johnston) writes: typedef struct _STRUCT_NAME {.....type struct_STRUCT_NAME is ....................................record int item1;..........................item1 : int; union { : int u_item1; : long u_item2; : } u_name; : int item2;..........................item2 : int; ....................................end record; } STRUCT_NAME;....................type STRUCT_NAME is new struct_STRUCT_NAME; The Ada (near) equivalent of a C union is a variant record, but you need a discriminant. I'll assume item1 is used as a discriminant in the C structure (good C code does include discriminants); that is, the value of item1 tells you whether to use u_item1 or u_item2. Then the Ada equivalent is: type DISCRIMINANTS is (One, Two); for DISCRIMINANTS use (One => ?, Two => ?); type struct_STRUCT_NAME (item1 : DISCRIMINANTS) is record case item1 is when One => u_item1 : int; when Two => u_item2 : int; end case; item2 : int end record; If item1 (or item2) is not used in this way, there is no direct Ada equivalent structure (and the C code is not very good!). - Stephe -- Stephen Leake, NASA Goddard Space Flight Center email: Stephen.Leake@gsfc.nasa.gov