By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,797 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,797 IT Pros & Developers. It's quick & easy.

When to use alternative argument layout?

P: n/a
I've read that as well as "normal" Java-like function definitions,
e.g. int main(int argc, char **argv), you can also choose to use an
alternative syntax, i.e.

int main(argc, argv)
int argc; char **argv;
{
....
}

I've been struggling to think of a situation where this alternative
form is more expressive than the usual one, but I guess I'm just not
imaginative enough :)

When do people prefer the alternative way, and why?

Mar 10 '07 #1
Share this Question
Share on Google+
11 Replies


P: n/a
Fr************@googlemail.com wrote:
I've read that as well as "normal" Java-like function definitions,
e.g. int main(int argc, char **argv), you can also choose to use an
alternative syntax, i.e.
There's nothing Java like about them, they are standard C.
int main(argc, argv)
int argc; char **argv;
{
....
}

I've been struggling to think of a situation where this alternative
form is more expressive than the usual one, but I guess I'm just not
imaginative enough :)

When do people prefer the alternative way, and why?
Never, it's an obsolete form that pre-dates C89.

--
Ian Collins.
Mar 10 '07 #2

P: n/a
>I've read that as well as "normal" Java-like function definitions,

Java has nothing to do with it.
>e.g. int main(int argc, char **argv), you can also choose to use an
alternative syntax, i.e.

int main(argc, argv)
int argc; char **argv;
{
...
}

I've been struggling to think of a situation where this alternative
form is more expressive than the usual one, but I guess I'm just not
imaginative enough :)
It's not. The main use of this form is for obsolete compilers that
don't accept the ANSI C function syntax. I know of one specific
one from 1983 that I've still got, but haven't used in over a decade.
>When do people prefer the alternative way, and why?
Hopefully never for new code on modern hardware. They might prefer
it if the only compiler available (at least for reasonable budgets)
accepts this form, and does not accept the ANSI C form. This would
tend to be mostly for "abandoned" processors. Another reason would
be to avoid doing massive changes to legacy code for what is maybe
supposed to be a minor change.

Mar 10 '07 #3

P: n/a
On 10 Mar 2007 14:33:23 -0800, in comp.lang.c ,
Fr************@googlemail.com wrote:
>I've read that as well as "normal" Java-like function definitions,
e.g. int main(int argc, char **argv),
Giggle. If anything, Java stole this style from C. Call it C-like...
>you can also choose to use an
alternative syntax, i.e.

int main(argc, argv)
int argc; char **argv;
This is an older, deprecated, pre ISO style dating back to the 1980s.
Don't use it.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Mar 11 '07 #4

P: n/a
Mark McIntyre wrote:
On 10 Mar 2007 14:33:23 -0800, in comp.lang.c ,
Fr************@googlemail.com wrote:
>I've read that as well as "normal" Java-like function definitions,
e.g. int main(int argc, char **argv),

Giggle. If anything, Java stole this style from C. Call it C-like...
But C stole it from C++ ...

(Or: For all the bad things one can say about That Other
Language, it has in fact produced a few improvements.)

--
Eric Sosman
es*****@acm-dot-org.invalid
Mar 11 '07 #5

P: n/a
Fr************@googlemail.com wrote:
I've read that as well as "normal" Java-like function definitions,
e.g. int main(int argc, char **argv),
This has nothing to do with Java. It was introduced to C, in the 1989
ANSI Standard, from C++. Java later on adopted it.
you can also choose to use an
alternative syntax, i.e.

int main(argc, argv)
int argc; char **argv;
{
...
}

I've been struggling to think of a situation where this alternative
form is more expressive than the usual one, but I guess I'm just not
imaginative enough :)

When do people prefer the alternative way, and why?
This is the older pre-C89 style of function declarations. It was
popularised by K&R 1 and was used in the 70s and mid-80s. One of the
major changes that the 1989 C Standard introduced was the newer type
of function declaration and definition, mainly to help compilers
perform stricter argument checking. The old form has been obsolete
ever since, though it's still syntactically accepted, because a lot of
old code uses it. Don't use it, except as an academic exercise. Use
the newer prototyped style. It's much better in terms of self-
documentation and, more importantly, allows the compiler to do
validation of arguments and cross-checking between declaration and
usage.

Mar 11 '07 #6

P: n/a
Thanks to everyone for the clarifications.

Mar 11 '07 #7

P: n/a
Gordon Burditt wrote:
>
I've read that as well as "normal" Java-like function definitions,

Java has nothing to do with it.
e.g. int main(int argc, char **argv), you can also choose to use an
alternative syntax, i.e.

int main(argc, argv)
int argc; char **argv;
[...]
The main use of this form is for obsolete compilers that
don't accept the ANSI C function syntax. I know of one specific
one from 1983 that I've still got, but haven't used in over a decade.
[...]

The last time I used an HP-UX system (post-2000), it would not
accept such syntax, chosing instead to give an error that it did
not support "ANSI prototypes".

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Mar 13 '07 #8

P: n/a
In article <45***************@spamcop.net>,
Kenneth Brody <ke******@spamcop.netwrote:
....
>The last time I used an HP-UX system (post-2000), it would not
accept such syntax, chosing instead to give an error that it did
not support "ANSI prototypes".
The "built-in"/default C compiler on HP/UX (at least when I worked on
it, which was last century) is very antedeluvian. It seems to be like
Sun, where the defaults are the very oldest versions of everything. You
have to use C89 (or something like that) to get the newfangled stuff.

Or some other C compiler, like gcc or such...

Mar 13 '07 #9

P: n/a
On Tue, 13 Mar 2007 11:58:21 -0400, Kenneth Brody
<ke******@spamcop.netwrote:
>Gordon Burditt wrote:
>>
>I've read that as well as "normal" Java-like function definitions,

Java has nothing to do with it.
>e.g. int main(int argc, char **argv), you can also choose to use an
alternative syntax, i.e.

int main(argc, argv)
int argc; char **argv;
[...]
>The main use of this form is for obsolete compilers that
don't accept the ANSI C function syntax. I know of one specific
one from 1983 that I've still got, but haven't used in over a decade.
[...]

The last time I used an HP-UX system (post-2000), it would not
accept such syntax, chosing instead to give an error that it did
not support "ANSI prototypes".
I suspect you were using the wrong compile options.

--
Al Balmer
Sun City, AZ
Mar 13 '07 #10

P: n/a
Al Balmer wrote:
>
On Tue, 13 Mar 2007 11:58:21 -0400, Kenneth Brody
<ke******@spamcop.netwrote:
Gordon Burditt wrote:
[...]
The main use of this form is for obsolete compilers that
don't accept the ANSI C function syntax. I know of one specific
one from 1983 that I've still got, but haven't used in over a decade.
[...]

The last time I used an HP-UX system (post-2000), it would not
accept such syntax, chosing instead to give an error that it did
not support "ANSI prototypes".

I suspect you were using the wrong compile options.
Nope. I researched it and found that the standard compiler supplied
by HP simply did not support this You had to buy a more expensive
version if you wanted that ability.

What got me about it was that they coded the recognition of the ANSI
style, and told you that it didn't support it. (Though I guess doing
it this way is a step up from just flagging some error. At least
this way, you don't waste time trying to track down your "error".)

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Mar 13 '07 #11

P: n/a
On Tue, 13 Mar 2007 14:40:10 -0400, Kenneth Brody
<ke******@spamcop.netwrote:
>Al Balmer wrote:
>>
On Tue, 13 Mar 2007 11:58:21 -0400, Kenneth Brody
<ke******@spamcop.netwrote:
>Gordon Burditt wrote:
[...]
>The main use of this form is for obsolete compilers that
don't accept the ANSI C function syntax. I know of one specific
one from 1983 that I've still got, but haven't used in over a decade.
[...]

The last time I used an HP-UX system (post-2000), it would not
accept such syntax, chosing instead to give an error that it did
not support "ANSI prototypes".

I suspect you were using the wrong compile options.

Nope. I researched it and found that the standard compiler supplied
by HP simply did not support this You had to buy a more expensive
version if you wanted that ability.
Ah, *that* one. That's used for some kind of maintenance activity and
not really intended for program development. You don't expect anything
useful without paying extra, do you? <g>.
>
What got me about it was that they coded the recognition of the ANSI
style, and told you that it didn't support it. (Though I guess doing
it this way is a step up from just flagging some error. At least
this way, you don't waste time trying to track down your "error".)
I suspect that the compiler shipped with HP-UX is a gutted version of
the standard one, so it probably retains warnings. The current (extra
cost) version of the PA-RISC compiler is actually pretty good. I
haven't seen a conformance statement, but it seems to support most of
C99. The Itanium compiler must have been a big development effort,
since it has to do all the optimizations that used to be in the
hardware. I haven't used it, since we've managed to make our product
run well under the Aries emulator.

--
Al Balmer
Sun City, AZ
Mar 13 '07 #12

This discussion thread is closed

Replies have been disabled for this discussion.