FAQ incorrect?

N

nroberts

In the faq for this group:

Q: What's the correct declaration of main()?

A: There are two valid declarations:

int main(void)
int main(int argc, char **argv)

although they can be written in a variety of ways. The second parameter
may be declared char *argv[] (see question 6.4), you can use any names
for the two parameters, and you can use old-style syntax:

int main()

int main(argc, argv)
int argc; char **argv;

.......... http://c-faq.com/ansi/maindecl.html

The way this is worded it makes one think that "int main()" is a valid
declaration of main. However, main is allowed to only take two params
of (int, char **) or 0, correct? In C is not an empty param list an
"unspecified" param list? In that case "int main()" would be invalid
as it matches neither of the standard signatures.

Another faq claiming to represent this group has the following text for
the same Q:

A: Either int main(), int main(void), or int main(int argc,
char *argv[]) (with alternate spellings of argc and *argv[]
obviously allowed). See also questions 11.12b to 11.15 below.

References: ISO Sec. 5.1.2.2.1, Sec. G.5.1; H&S Sec. 20.1 p.
416; CT&P Sec. 3.10 pp. 50-51.

............... http://www.faqs.org/faqs/C-faq/faq/

It also has "int main()" but has no reasoning for its validity except
ref to the std I don't have access to. Is that truely a valid
signature? I always thought you _needed_ (void).
 
A

Andrey Tarasevich

nroberts said:
...
although they can be written in a variety of ways. The second parameter
may be declared char *argv[] (see question 6.4), you can use any names
for the two parameters, and you can use old-style syntax:

int main()

int main(argc, argv)
int argc; char **argv;

......... http://c-faq.com/ansi/maindecl.html

The way this is worded it makes one think that "int main()" is a valid
declaration of main. However, main is allowed to only take two params
of (int, char **) or 0, correct? In C is not an empty param list an
"unspecified" param list? In that case "int main()" would be invalid
as it matches neither of the standard signatures.

The way it is worded (seeing the "old-style syntax" mentioned and so on) makes
it clear that it is specifically referring to the declaration of 'main', which
is a part of _definition_ of 'main'. When the empty parameter list '()' is used
in a definition, it always means 'no parameters' (equivalent to '(void)'), not
'unspecified parameters'.
...
It also has "int main()" but has no reasoning for its validity except
ref to the std I don't have access to. Is that truely a valid
signature? I always thought you _needed_ (void).
...

Only in the declaration that is not a definition. In a definition '()' and
'(void)' mean the same thing - no parameters.
 
W

Walter Roberson

In the faq for this group:
Q: What's the correct declaration of main()?
for the two parameters, and you can use old-style syntax:
int main()
The way this is worded it makes one think that "int main()" is a valid
declaration of main.

It is.
However, main is allowed to only take two params
of (int, char **) or 0, correct? In C is not an empty param list an
"unspecified" param list?

According to C89 3.5.4.3, an empty parameter list in a function
definition indicates that the function takes no parameters. A single
parameter of void indicates that the function takes no parameters.

In a function declaration that is not the function definition,
then the empty parameter list does indicate unspecified arguments.
 
A

Andrey Tarasevich

Andrey said:
...
Only in the declaration that is not a definition. In a definition '()' and
'(void)' mean the same thing - no parameters.
...

Of course, one might argue that the FAQ should state it explicitly that the
declaration being discussed is actually the _definition_ of 'main'. The standard
actually uses the term 'definition' when it list the valid forms of 'main'.
 
R

Richard Heathfield

jacob navia said:
Walter Roberson wrote:
According to C89 3.5.4.3,

[snip]

Irrelevant since that standard is no longer valid.

It's perfectly valid according to a large number of compilers that support
it and a huge number of programmers who use it. If we were to consider C89
as invalid, then we would have no valid, widely-implemented C standard,
which would be a ridiculous state of affairs.
 
K

Kenny McCormack

jacob navia said:
Walter Roberson wrote:
According to C89 3.5.4.3,

[snip]

Irrelevant since that standard is no longer valid.

It's perfectly valid according to a large number of compilers that support
it and a huge number of programmers who use it. If we were to consider C89
as invalid, then we would have no valid, widely-implemented C standard,
which would be a ridiculous state of affairs.

But, but, but. Wait a second! Phrases like "large number of
compilers", "huge number of programmers", "widely implemented" and
"ridiculous" (this last in the sense of "a condition or position to be
avoided") have no place in and no traction in CLC. Such references to a
stupid (not to mention, inconvenient) little thing known as reality
clearly have no place here. In fact, they are flash-point words that
uniformly stir the "regs" to action/flaming.

Really, you need to re-think that post or you may lose your place in the
he-man newbie-hating society.
 
N

nroberts

Kenny said:
Really, you need to re-think that post or you may lose your place in the
he-man newbie-hating society.

Hehehe...always interesting how one can inadvertently stir up a bee's
nest...

Thanks for the answers, guys.
 
A

Andrew Poelstra

Hehehe...always interesting how one can inadvertently stir up a bee's
nest...

If by `one' you mean yourself, you did nothing wrong. If by `one' you
mean McCormack, it wasn't inadvertent. He's a troll, and it's best you
don't respond to his deranged mutterings.
 
K

Keith Thompson

jacob navia said:
Walter said:
It is.

According to C89 3.5.4.3,

[snip]

Irrelevant since that standard is no longer valid.

So I can safely ignore C89/C90 and program strictly in C99? And I can
freely use features like, say, designated initializers and structure
initializers with the dot notation, and not have to worry that some
compiler might not implement them?

You wrote two days ago, in comp.compilers.lcc, that lcc-win32 doesn't
implement those features. Does that mean that lcc-win32 isn't a real
C compiler?

You've argued at times that compiler-specific extensions should be
considered topical here, and at other times that nothing other than
the C99 standard is topical (as opposed to the generally accepted
guideline that C99, C95, C89/C90, K&R C, and even earlier versions of
the language are topical, the latter mostly in historical context).

If you'll put together a coherent and consistent set of topicality
guidelines, let us know and we might consider it (no guarantees of
course) -- or maybe you can set up your own alt.* newsgroup. Until
then, perhaps you'd consider letting the rest of us work these things
out for ourselves.

It is a fact that the C90 standard is still very relevant, and this
newsgroup is the appropriate place to discuss it, your fantasies to
the contrary notwithstanding.
 
K

Kenny McCormack

If by `one' you mean yourself, you did nothing wrong. If by `one' you
mean McCormack, it wasn't inadvertent. He's a troll, and it's best you
don't respond to his deranged mutterings.

Pot, kettle, black.
 
J

jacob navia

Richard said:
jacob navia said:
Walter Roberson wrote:
According to C89 3.5.4.3,

[snip]

Irrelevant since that standard is no longer valid.


It's perfectly valid according to a large number of compilers that support
it and a huge number of programmers who use it. If we were to consider C89
as invalid, then we would have no valid, widely-implemented C standard,
which would be a ridiculous state of affairs.

OK OK.

When I bring a large number of compilers in many OSes
that support

#pragma once

you tell me that it is non-standard.

When I say that the standard is now

int main(void or int main(int argc,char *argv[])

you start with a large number of compilers that support C89.

There are many compilers that support the K&R standard (without
prototypes).

Should we recommned new users that they use that?

Let's standardize in the standard we use: :)

The *current* standard.

The rest is HISTORICAL and just confuses people
 
R

Richard Heathfield

jacob navia said:
Richard said:
jacob navia said:
Walter Roberson wrote:

According to C89 3.5.4.3,

[snip]

Irrelevant since that standard is no longer valid.


It's perfectly valid according to a large number of compilers that
support it and a huge number of programmers who use it. If we were to
consider C89 as invalid, then we would have no valid, widely-implemented
C standard, which would be a ridiculous state of affairs.

OK OK.

When I bring a large number of compilers in many OSes
that support

#pragma once

you tell me that it is non-standard.

But your idea of "large number" is a relatively small number, whereas the
number of compilers conforming to C89 is considerably greater. In fact,
you'd be hard-pressed to find a C compiler in current use that did not
conform to C89 (modulo the odd bug), whereas it is so easy to find a C
compiler that does not support #pragma once that you managed it all by
yourself.
When I say that the standard is now

int main(void or int main(int argc,char *argv[])

you'd be wrong, because the first of your examples is a parenthesis short of
a declarator.
you start with a large number of compilers that support C89.

Indeed. Note that int main(void) and int main(int argc, char *argv[]) or
their equivalents have been the forms recommended by clc for many years, so
I don't see what point you're trying to make here.
There are many compilers that support the K&R standard (without
prototypes).

Sure. Whilst they do not conform to C89 (at least, when invoked in K&R
mode), they nevertheless may prove useful to some people. K&R C is still
topical here.
Should we recommned new users that they use that?

Only if they are obliged to use K&R compilers.
Let's standardize in the standard we use: :)

It's not up to you and me to determine which flavours of C are topical here.
By longstanding convention, K&R C, C90, and now C99 are all topical in clc.
The *current* standard.

Fine, as soon as it becomes as widely implemented as C90 currently is, which
won't be for many years.
The rest is HISTORICAL and just confuses people

The kind of people who make good computer programmers are not the kind of
people to be confused easily by the fact that a newsgroup might discuss K&R
C, C90, /and/ C99.
 
F

Frederick Gotham

Troll Alert: Kenny McCormack

The only way to deal with trolls is to limit your reaction to reminding
others not to respond to trolls.
 
F

Frederick Gotham

Troll Alert: Kenny McCormack

The only way to deal with trolls is to limit your reaction to reminding
others not to respond to trolls.
 
K

Keith Thompson

jacob navia said:
Richard said:
jacob navia said:
Walter Roberson wrote:
According to C89 3.5.4.3,

[snip]

Irrelevant since that standard is no longer valid.
It's perfectly valid according to a large number of compilers that
support it and a huge number of programmers who use it. If we were
to consider C89 as invalid, then we would have no valid,
widely-implemented C standard, which would be a ridiculous state of
affairs.

OK OK.

When I bring a large number of compilers in many OSes
that support

#pragma once

you tell me that it is non-standard.

Yes, because it is.
When I say that the standard is now

int main(void or int main(int argc,char *argv[])

you start with a large number of compilers that support C89.

I don't see your point here; that didn't change between C89 and C99
(except for C99's explicit permission to have more
implementation-defined forms, but extensions were already permitted).
There are many compilers that support the K&R standard (without
prototypes).

Should we recommned new users that they use that?

Of course not. There are few C compilers still in common use that
don't support at least the C89/C90 standard reasonably well. There
are even fewer platforms still in common use that don't have at least
*some* compiler that supports at least the C89/C90 standard, even if
the native compiler doesn't. There is no longer very much point in
worrying about pre-C89 compilers. On the other hand, if any users run
into a situation where they need to program in C on a system with no
modern compiler available, yes, this would be the place to ask for
advice.
Let's standardize in the standard we use: :)

The *current* standard.

The rest is HISTORICAL and just confuses people

One more time. The full C89/C90 standard is widely implemented. The
C99 standard is not. Not everyone uses, or is able to use, the C99
standard. Even your own lcc-win32 doesn't implement all of it. That
is reality.

Will you, just once, *acknowledge* that plain fact? Or will you
continue to deny reality and make a fool of yourself? (I think I
already know the answer, but I'm always prepared to be pleasantly
surprised.)
 
F

Frederick Gotham

The only way to deal with trolls is to limit your reaction to reminding
others not to respond to trolls.
 
K

Keith Thompson

Frederick Gotham said:
The only way to deal with trolls is to limit your reaction to reminding
others not to respond to trolls.

Yes, we know.

Usually someone posts a single followup to anyone who responds to the
troll in question, and that generally works reasonably well. Starting
a new thread gives the troll more attention.
 
J

Jack Klein

Walter said:
It is.




According to C89 3.5.4.3,

[snip]

Irrelevant since that standard is no longer valid.

Jacob, you're getting to be a real PITA. Since the text is
essentially the same in the current standard, it makes no real
difference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top