[comp.sys.atari.st] Sozobon C starter question

J.J. Lehett <JJL101@psuvm.psu.edu> (04/17/91)

     I am getting an error which I am not sure why with this line:

     main( int argc, char **argy)

    that says it is expecting a )

    but if I change that to:    main()

     I do not get that problem... any idea as to why?

      Thanks in advance,

*************************************************************************
*     J.J.      *  Internet: JJL101@PSUVM.PSU.EDU  *     Penn State     *
*               *                                  *     Center for     *
*  John Lehett  *  Bitnet:   JJL101@PSUVM          * Academic Computing *
*************************************************************************
*                  Limit(Continuous Luck) = Skill                       *
*************************************************************************

jbleaza%peruvian.utah.edu@cs.utah.edu (Jason Bleazard) (04/18/91)

In article <91107.154833JJL101@psuvm.psu.edu> J.J. Lehett <JJL101@psuvm.psu.edu> writes:
>     I am getting an error which I am not sure why with this line:
>
>     main( int argc, char **argy)
>
>    that says it is expecting a )
>
>    but if I change that to:    main()
>
>     I do not get that problem... any idea as to why?
>
>      Thanks in advance,
>
>*************************************************************************
>*     J.J.      *  Internet: JJL101@PSUVM.PSU.EDU  *     Penn State     *
>*               *                                  *     Center for     *
>*  John Lehett  *  Bitnet:   JJL101@PSUVM          * Academic Computing *
>*************************************************************************
>*                  Limit(Continuous Luck) = Skill                       *
>*************************************************************************

Sozobon expects this really arcane method of passing parameters.
In the above example, try:

       main(argc, argy)
       int argc;
       char **argy;
       {
       }

Someone told me that this is the old method of passing parameters.
One advantage is that you can say
void foo(x, y, z)
int x, y, z;
{}
instead of
void foo(int x, int y, int z) 
{}

In other words, you only have to type int once.  (Yay)

-Jaysan

steve@thelake.mn.org (Steve Yelvington) (04/18/91)

[In article <1991Apr17.143748.13488@hellgate.utah.edu>,
     jbleaza%peruvian.utah.edu@cs.utah.edu (Jason Bleazard) writes ... ]

> Sozobon expects this really arcane method of passing parameters.

It's not arcane (any more than the rest of C). Archaic, if you want to
consider most C compilers available for the ST as archaic. Mark Williams,
Laser C, Sozobon and Alcyon all use the traditional K&R form.

It's the way parameters were passed in C before the idea of function
prototypes was endorsed by ANSI. GCC and Prospero C understand the
newer format. Lattice may as well (I haven't seen it).

Sozobon follows the original Kernighan and Ritchie definition of C, with
some common extensions. Some of those extensions happen to be part of the
(fairly new) ANSI standard, and the library largely follows the ANSI
standard, but the current Sozobon C does not pretend to be an
ANSI-conformant compiler.

There was a preprocessor posted to the network (comp.os.minix) a year or
so ago that purported to convert ANSI C files to K&R style. I don't know
if it was ever ported to TOS. (If so, I want a copy!)

Dan Wilga of Gribnif Software recently released a K&R-to-ANSI converter
called OLD2ANSI. It's on GENie.

 ----
 Steve Yelvington, Marine on St. Croix, Minnesota, USA / steve@thelake.mn.org

warwick@cs.uq.oz.au (Warwick Allison) (04/19/91)

>>     I am getting an error which I am not sure why with this line:
>>
>>     main( int argc, char **argy)
>>
>Sozobon expects this really arcane method of passing parameters.
>In the above example, try:

>       main(argc, argy)
>       int argc;
>       char **argy;
>       {
>       }

Yes.  Sozobon is K&R C, while gcc is ANSI.  Get gcc (if you have the space
on your HD), as it is FAR superior, it even produces much fater code.

Warwick.
--
  _--_|\   	warwick@cs.uq.oz.au
 /      *  <--	Computer Science Department,
 \_.--._/ 	University of Queensland,
       v    	AUSTRALIA.

jclark@sdcc6.ucsd.edu (John Clark) (04/29/91)

In article <1991Apr17.143748.13488@hellgate.utah.edu> jbleaza%peruvian.utah.edu@cs.utah.edu (Jason Bleazard) writes:
+
+Sozobon expects this really arcane method of passing parameters.
+In the above example, try:
+
+       main(argc, argy)
+       int argc;
+       char **argy;

Arcane???!!! Try as documented in the K&R white book. The ANSI
standard method what is listed below. Some notable and wide spread C
compilers, such as Sun OS4.1, still use the 'arcane' method.

The ANSI method also allows the 'function prototype' to be used and
the syntax is the same for either the prototype or the function
definition, where as the K&R method would have been a botch.

E.g. in ANSI
int funct( int p1, struct str *p2);	/* function prototype.	*/
	...
int funct( int p1, struct str *p2)	/* function definition.	*/
{
	......
}

This concept is a 'logical' extention of the C idea that one can
'add' to the definition of a variable as one proceeds, such as

extern int array[];	/* first mention of 'array' and typing it.  */
	....
int array[100];		/* Further definition.			*/

This allows the 'include' files to declare 'array' external for all
modules using 'array' and also allows array to be defined explicitly
as required in the definition module.

-- 

John Clark
jclark@ucsd.edu