delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/11/11/11:01:54

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Hannu E K Nevalainen" <garbage_collector AT telia DOT com>
To: "ML CygWIN" <cygwin AT cygwin DOT com>
Subject: exit status <-> portable code
Date: Tue, 11 Nov 2003 17:01:16 +0100
Message-ID: <NGBBLLIAMFLGJEOAJCCEOECKDGAA.garbage_collector@telia.com>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
Importance: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165

#define "exit status" "return code"

 I dispise literal numbers in code - it lessens readabilty, portability and
maybe one or two "-bility's" more.

e.g: When using AmigaDOS headers for console mode program/command
development I have this available:

$ tail +230 /Amiga/NDU31/include/dos/dos.h | head -6
/* These are the return codes used by convention by AmigaDOS commands */
/* See FAILAT and IF for relvance to EXECUTE files                    */
#define RETURN_OK        0  /* No problems, success */
#define RETURN_WARN      5  /* A warning only */
#define RETURN_ERROR    10  /* Something wrong */
#define RETURN_FAIL     20  /* Complete or severe failure*/

Using these I can write programs that look like:

$ cat hickup.c
#include <stdio.h>
#include <dos/dos.h>

int main(...) {
  int success=RETURN_FAIL;

  if (all_OK)
    success=RETURN_OK;

  return success;
}

Q: Is there anything within Cygwin (or Linux, Net*, U*X, whatever... that
can be transferred to Cygwin) that can be used for the same purpose?

/Hannu E K Nevalainen, B.Sc. EE - 59+16.37'N, 17+12.60'E
-- printf("LocalTime: UTC+%02d\n",(DST)? 2:1); --
--END OF MESSAGE--


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019