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 Path: g2news2.google.com!postnews.google.com!z16g2000prd.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: How to exit an Ada program with (unix shell) error code? Date: Tue, 5 May 2009 07:57:26 -0700 (PDT) Organization: http://groups.google.com Message-ID: <62b174a9-c9c5-479c-9dd6-71916c102eb0@z16g2000prd.googlegroups.com> References: <49ba30c9-a1e6-4346-8618-d256f87ac301@s31g2000vbp.googlegroups.com> <8ef6052e-4f51-416b-bae7-ff83d7024267@t11g2000vbc.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1241535446 14199 127.0.0.1 (5 May 2009 14:57:26 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 5 May 2009 14:57:26 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z16g2000prd.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5692 Date: 2009-05-05T07:57:26-07:00 List-Id: On May 5, 4:43 am, Martin wrote: > On May 4, 5:09 pm, a...@anon.org (anon) wrote: > > > -- > > -- Besides the Ada.Command_Line you can just use functions for > > -- the instead of procedures for your nain program. This design is > > -- great for application where Command_Line is not used. > > -- > > > function work return Integer is > > > begin > > return ( 0 ) ; -- no error status code > > end work ; > > Be aware that this is not portable. The only main subprogram that all > compilers must support (if they support a main subprogram) is "public > parameterless library procedures" (RM2005 10.2, 29 - previous RMs have > similar requirements), i.e. > > procedure Main is > ... > > Cheers > -- Martin Right; and even if your Ada compiler *does* support functions that return integers as main programs, and you're compiling for some operating system with an "x" in its name (or Solaris), this does *not* mean that the Ada compiler will treat the function result as the status code. The compiler could decide that the function result is something to be formatted and spit out onto standard output. If an Ada implementation supports parameters and/or function results on main programs, the language leaves it up to the implementation how those are interpreted. There's no rule that says that the interpretation has to mimic the behavior of the C language (thank God). So anon's solution may work on GNAT, but it can't be assumed to work anywhere else. -- Adam