473,770 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FAQ incorrect?

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
"unspecifie d" 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).

Aug 4 '06 #1
49 1708
nroberts wrote:
...
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
"unspecifie d" 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.

--
Best regards,
Andrey Tarasevich
Aug 4 '06 #2
In article <11************ *********@b28g2 000cwb.googlegr oups.com>,
nroberts <ro**********@g mail.comwrote:
>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.
--
Programming is what happens while you're busy making other plans.
Aug 4 '06 #3
Andrey Tarasevich wrote:
...
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'.

--
Best regards,
Andrey Tarasevich
Aug 4 '06 #4
Walter Roberson wrote:
In article <11************ *********@b28g2 000cwb.googlegr oups.com>,
nroberts <ro**********@g mail.comwrote:
>>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
"unspecifie d" param list?


According to C89 3.5.4.3,
[snip]

Irrelevant since that standard is no longer valid.
Aug 4 '06 #5
jacob navia said:
Walter Roberson wrote:
<snip>
>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.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Aug 4 '06 #6
In article <S6************ ********@bt.com >,
Richard Heathfield <in*****@invali d.invalidwrote:
>jacob navia said:
>Walter Roberson wrote:
<snip>
>>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.

Aug 4 '06 #7

Kenny McCormack wrote:
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.

Aug 4 '06 #8
On 2006-08-04, nroberts <ro**********@g mail.comwrote:
>
Kenny McCormack wrote:
>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...
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.

--
Andrew Poelstra <http://www.wpsoftware. net/projects>
To reach me by email, use `apoelstra' at the above domain.
"Do BOTH ends of the cable need to be plugged in?" -Anon.
Aug 4 '06 #9
jacob navia <ja***@jacob.re mcomp.frwrites:
Walter Roberson wrote:
>In article <11************ *********@b28g2 000cwb.googlegr oups.com>,
nroberts <ro**********@g mail.comwrote:
>>>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
declaratio n 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,

[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 .

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 4 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
14399
by: Michelle Hillard | last post by:
Hi guys, would appreciate if you can shed some light on this. Sorry to be a pain, can you tell me what is wrong with the following: for /F %%i in ('dir /b /on c:\bcp\pc*.txt') do bcp Inventory..pc in %%i -fc:\bcp\bcp.fmt -T -S CHICKYy where CHICKYy is the server bcp.fmt
2
1280
by: Linda Wienholt | last post by:
I have two usercontrols on the home page of my website. They are intermitently sending incorrect HTML to the browser, which results in a textbox being rendered with the wrong width. Either both controls render correctly or both are incorrect but never a mixture. When they are rendered correctly the source looks like <input name="Header2:txtKeyword" type="text" id="Header2_txtKeyword" style="width:80px;" / When incorrect the source looks...
1
3931
by: murphy | last post by:
Hi, I've been seeing two symptoms with my asp.net site that have started recently after a long period of smooth running. As others on our team make changes to referenced dll's I find that I get the following errors from time to time. Apparently the following procedure alleviates the problems: -Reboot (clears locks on following directory)
3
3350
by: murphy | last post by:
Hi, I've been seeing two symptoms with my asp.net site that have started recently after a long period of smooth running. As others on our team make changes to referenced dll's I find that I get the following errors from time to time. Apparently the following procedure alleviates the problems:
4
2756
by: Peter Ritchie | last post by:
Does anyone know how to suppress a specific warning for a line or block of code in C#? C++ has a nice facility to disable a warning for a block of code with #pragma for warnings that are incorrect or don't apply. For example, the following code generates an CS0628 because CS0628 makes an incorrect assumption that "protected" applies only to inheritance: public sealed class Class { EmbeddedClass utility = new EmbeddedClass();
6
2648
by: ypjofficial | last post by:
HI, I have following terrific confusion. class test { public: int i; int * j; int **k;
2
4858
by: mankolele | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Simple Database Connection</title> </head> <body bgcolor="white"> <?php $connection = mysql_connect("localhost", "root", "phpmysql"); $select_db = mysql_select_db("procdumy", $connection);
6
8598
by: trevor | last post by:
Incorrect values when using float.Parse(string) I have discovered a problem with float.Parse(string) not getting values exactly correct in some circumstances(CSV file source) but in very similar circumstances(XML file source) and with exactly the same value it gets it perfectly correct all the time. These are the results I got, XML is always correct, CSV are only incorrect for some of the values (above about 0.01) but always gives the...
1
2405
by: ndawg123 | last post by:
Hey guys what im trying to do is write a yatzee game with C. And im stuck already and its the start?!?! I want the user to type there 5 numbers. i.e My program so far does this Please enter dice Values:
0
8329
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new records there is an error "Incorrect syntax near '-'. Must declare the scalar variable "@UserName". I worked out in design view,code is automatically generated.Iam not able fix the error. Iam working with Visual Web Developer-2005 Express Edition
0
9595
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8891
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.