[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Aztec C: C ++??



In article <1ifj9fc.1ugv32wa5s2zdN%dempson@actrix.gen.nz>,
David Empson <dempson@actrix.gen.nz> wrote:

>I'd have to hunt through old documentation to find the other major
>differences as I've been using ANSI C so long I'm somewhat hazy on what
>else was missing from the language in earlier versions.

Some other differences were:

In ANSI C, struct's can be passed by value to functions and a function
can have a struct as its return value.  In K&R C you could only do that
with pointers to struct's.  And I think software like ANSI2KNR would
have a quite hard time handling THAT case..... memory would have to
be allocated for these struct parameters and automatically deallocated
at the proper place.... I think you get the idea...

In ANSI C, float arithmetic is allowed - in K&R C, real arithmetic always
had to be performed as double arithmetic.

A number of predefined macros was added to ANSI C.

A number of new library functions was added to ANSI C.  And in ANSI C,
the standard library became part of the language - that was not the
case with K&R C.

In ANSI C, calling a pointer to a function could be performed with
the regular function call syntax.  One example:

    int (*fptr)(int,int);

......

    fptr = some_function;

......

In ANSI C, this is legal while in K&R C it's a syntax error:

    fptr(23,45);

In K&R C you *had* to call the function pointer like this:

    (*fptr)(23,45);

That was legal too in ANSI C - even for a regular function!  Thus, in
ANSI C you can also do:

    (*printf)("Hello, world\n");

would would be illegal in K&R C.  In ANSI C you can even do:

    (*****************************************printf)("Hello, world\n");

and it works !!!!


In ANSI C you can do "string pasting", e.g.:

    char *s = "First part of string, "   "second part of string";

In K&R C you had to do it like this:

    char *s = "First part of string, second part of string";

or like this:

    char *s = "First part of string, \
second part of string";

which looks a bit ugly....


String pasting is particularly handy when you have strings defined
as macros - you can then paste them together by just writing the
macro names one after another.

-- 
----------------------------------------------------------------
Paul Schlyter,  Grev Turegatan 40,  SE-114 38 Stockholm,  SWEDEN
e-mail:  pausch at stjarnhimlen dot se
WWW:     http://stjarnhimlen.se/