Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: Dan.Pop@cern.ch (Dan Pop)
Subject: Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA *
Date: 1998/09/07	[thread overview]
Message-ID: <danpop.905201603@news.cern.ch> (raw)
In-Reply-To: 6t18af$p83$1@Starbase.NeoSoft.COM

In <6t18af$p83$1@Starbase.NeoSoft.COM> jordan@Starbase.NeoSoft.COM (Jordan Henderson) writes:

>In article <6svdad$ggd@web.nmti.com>,
>Peter da Silva <peter@baileynm.com> wrote:
>>In article <6ssnp9$6pv$1@Starbase.NeoSoft.COM>,
>>Jordan Henderson <jordan@Starbase.NeoSoft.COM> wrote:
>>
>>> I think that, conceptually, the handling of command line arguments is
>>> part of the core language.  What >is< part of the core language and what is 
>>> not?  And what is your justification for the separation?
>>
>>Basically, I think that the distinction between a hosted and embedded
>>implementation is a good place to start.
>>
>
>I still don't have the Standard document at hand, but does it clearly 
>say that non-hosted systems cannot have command line arguments?

It just doesn't say anything about this issue WRT freestanding
(non-hosted) environments.  There is nothing in the standard preventing
freestanding environments from providing access to command line
arguments, if the very concept of "command line argument" has any 
meaning for that particular freestanding environment.  But the mechanism
used to pass them is not necessarily the same as in the case of a hosted 
environment (the arguments of main()).

>I know that VRTX (and probably lots of other) real-time OS's allow you
>to write programs that have command lines (they implement exec(), so 
>you have to have arguments).
>
>What exactly is the difference between hosted and non-hosted environments?

I'll append the exact text from the standard.  In a nutshell, a hosted
environment benefits from the existence of an operating system, while a
freestanding one doesn't.  Think of a workstation versus a toaster.

BTW, the operating system *itself* is running in a freestanding environment.
To some operating systems you can pass command line arguments (e.g. this
is how you boot most Unices in single user mode), to others you can't
(e.g. CP/M, MS-DOS, Windows 95).

>Even if command line arguments are not supported in non-hosted environments,
>I have the string constants to fall back on for my claim that nul-terminated
>strings are a "feature" of the language. 

Indeed, they are a feature of the language.

Dan


2.1.2.1 Freestanding environment

In a freestanding environment (in which C program execution may
take place without any benefit of an operating system), the name and
type of the function called at program startup are
implementation-defined.  There are otherwise no reserved external
identifiers.  Any library facilities available to a freestanding
program are implementation-defined.

The effect of program termination in a freestanding environment is
implementation-defined.

2.1.2.2 Hosted environment

A hosted environment need not be provided, but shall conform to the
following specifications if present.

"Program startup"

The function called at program startup is named main .  The
implementation declares no prototype for this function.  It can be
defined with no parameters:

         int main(void) { /*...*/ }

or with two parameters (referred to here as argc and argv , though any
names may be used, as they are local to the function in which they are
declared):

         int main(int argc, char *argv[]) { /*...*/ }


If they are defined, the parameters to the main function shall obey
the following constraints:

 * The value of argc shall be nonnegative.  

 * argv[argc] shall be a null pointer.  

 * If the value of argc is greater than zero, the array members
   argv[0] through argv[argc-1] inclusive shall contain pointers to
   strings, which are given implementation-defined values by the host
   environment prior to program startup.  The intent is to supply to the
   program information determined prior to program startup from elsewhere
   in the hosted environment.  If the host environment is not capable of
   supplying strings with letters in both upper-case and lower-case, the
   implementation shall ensure that the strings are received in
   lower-case.

 * If the value of argc is greater than zero, the string pointed to by
   argv[0] represents the program name ;argv[0][0] shall be the null
   character if the program name is not available from the host
   environment.  If the value of argc is greater than one, the strings
   pointed to by argv[1] through argv[argc-1] represent the program
   parameters .

 * The parameters argc and argv and the strings pointed to by the argv
   array shall be modifiable by the program, and retain their last-stored
   values between program startup and program termination.

"Program execution"

In a hosted environment, a program may use all the functions,
macros, type definitions, and objects described in the library section ($4).

"Program termination"

A return from the initial call to the main function is equivalent
to calling the exit function with the value returned by the main
function as its argument.  If the main function executes a return that
specifies no value, the termination status returned to the host
environment is undefined.


--
Dan Pop
CERN, IT Division
Email: Dan.Pop@cern.ch 
Mail:  CERN - EP, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland



  parent reply	other threads:[~1998-09-07  4:00 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0095000017115526000002L062*@MHS>
     [not found] ` <35E04DF1.1911@world.std.com>
     [not found]   ` <35E09E76.6773@earthlink.net>
1998-08-23  4:00     ` Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * Terry C. Shannon
1998-08-23  4:00       ` Glenn C. Everhart
1998-08-24  4:00         ` Paul Sture
1998-08-25  4:00           ` Gregg E Economou
1998-08-25  4:00             ` Jordan Henderson
1998-08-26  4:00               ` Bob Koehler
     [not found]                 ` <6s910k$2bo$1@Starbase.NeoSoft.COM>
1998-08-29  4:00                   ` Gregg E Economou
1998-08-30  4:00                     ` Jay Maynard
     [not found]                   ` <35e833be.0@news.wizvax.net>
1998-08-29  4:00                     ` Jordan Henderson
1998-08-30  4:00                       ` John Wilson
1998-08-30  4:00                         ` JF Mezei
1998-08-30  4:00                           ` Chris Torek
1998-08-31  4:00                             ` Gregg E Economou
1998-08-31  4:00                               ` Chris Torek
1998-08-30  4:00                         ` Lawrence Kirby
1998-08-30  4:00                           ` JF Mezei
1998-08-30  4:00                             ` Martin Ambuhl
1998-08-31  4:00                             ` Craig Franck
1998-08-30  4:00                               ` JF Mezei
1998-08-31  4:00                                 ` firewind
     [not found]                             ` <6scur7$qtk@bgtnsc02.wo <35EA0E22.C59E9476@videotron.ca>
1998-08-31  4:00                               ` Will Rose
1998-08-31  4:00                             ` Michael Rubenstein
1998-09-04  4:00                         ` Thor Lancelot Simon
1998-08-30  4:00                       ` Gregg E Economou
1998-08-30  4:00                         ` K&R fight over ketchup (was: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA ) Clint Comes
1998-08-31  4:00                           ` Bob Koehler
1998-09-05  4:00                             ` Gregg E Economou
1998-09-05  4:00                       ` Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * Peter da Silva
1998-09-05  4:00                         ` Jordan Henderson
1998-09-07  4:00                           ` Peter da Silva
1998-09-07  4:00                             ` Jordan Henderson
1998-09-07  4:00                               ` Peter da Silva
1998-09-07  4:00                                 ` Jordan Henderson
1998-09-08  4:00                                   ` Peter da Silva
1998-09-08  4:00                                     ` Peter da Silva
     [not found]                                     ` <6t2im5$mke@espresso.cafe.net>
1998-09-08  4:00                                       ` Peter da Silva
1998-09-08  4:00                                   ` Tim Shoppa
     [not found]                                     ` <6t4cui$hfu@espresso.cafe.net>
1998-09-09  4:00                                       ` Tim Shoppa
1998-09-08  4:00                                         ` JF Mezei
1998-09-09  4:00                                         ` Dan Pop
1998-09-09  4:00                                           ` Peter da Silva
1998-09-08  4:00                                   ` JF Mezei
1998-09-08  4:00                                 ` Dan Pop
1998-09-08  4:00                                   ` Peter da Silva
1998-09-08  4:00                                     ` Dan Pop
1998-09-07  4:00                               ` Dan Pop [this message]
1998-09-07  4:00                               ` Richard Stamp
1998-08-25  4:00             ` John Wilson
1998-08-26  4:00               ` Gregg E Economou
1998-08-27  4:00                 ` John Wilson
1998-08-26  4:00             ` Bob Koehler
1998-08-27  4:00               ` Thor Lancelot Simon
1998-08-28  4:00                 ` TERENCE MURPHY
1998-08-28  4:00                   ` Greg Thomas
1998-08-29  4:00                     ` mathog
1998-09-01  4:00                       ` Greg Thomas
1998-08-28  4:00                   ` Monty Brandenberg
1998-08-28  4:00                   ` George Cornelius
1998-08-29  4:00                   ` Gregg E Economou
1998-09-05  4:00                   ` Peter da Silva
1998-08-28  4:00                 ` Bob Koehler
1998-09-05  4:00                   ` Peter da Silva
1998-09-08  4:00                     ` Carl Perkins
1998-08-31  4:00                 ` Boris
1998-08-27  4:00               ` Peter da Silva
1998-08-31  4:00                 ` Boris
1998-08-26  4:00             ` Paul Sture
1998-08-27  4:00               ` Gregg E Economou
1998-08-28  4:00                 ` Paul Sture
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox