Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Chess programming puzzle

Author: Dann Corbit

Date: 14:34:27 02/22/05

Go up one level in this thread


On February 22, 2005 at 16:36:32, Tom Likens wrote:

>On February 22, 2005 at 15:50:21, Dann Corbit wrote:
>
>>On February 22, 2005 at 15:45:02, Tom Likens wrote:
>>[snip]
>>>Tim,
>>>
>>>You could make this slightly shorter by declaring main void and getting rid
>>>of that "return 0" at the end! ;-)
>>
>>From the C-FAQ:
>>1.25b:  What's the right declaration for main()?
>>        Is void main() correct?
>>
>>A:      See questions 11.12a through 11.15.  (But no, it's not correct.)
>
>[--snip--]
>
>Hey Dann,
>
>Well, if you're gonna go by the standard how will we *ever* get anything done??
>
>;-)
>

A complete, fully functional chess engine can be written entirely using ANSI/ISO
standard C or C++.

The void main() thingy is actually a real concern.

I actually crashed someone's machine by sending them a spigot algorithm program
to compute pi.  The machine was called an Acorn (some kind of British computer
IIRC) and with the particular C compiler in use, execution of a C program with
main declared as void brought down the OS.

There is nothing wrong with going outside the bounds of the standard when it is
needed (which is often).  For instance, ANSI/ISO C does not support any sort of
graphics, and so Winboard, Arena or any other chess GUI cannot be performed in
ANSI/ISO C or C++.  So you can use an additional ANSI/ISO standard like GKS,
PHIGS:
http://www.iso.org/iso/en/CatalogueListPage.CatalogueList?COMMID=117&scopelist=
or a non-ANSI/ISO standard like OpenGL:
http://www.opengl.org/
Or you can use a vendor specific API:
http://www.phptr.com/title/0130869856

or something that is a custom API with no particular standard involved.

But if you do not need to deviate from the standard, then it is not a good idea
to do it.

It will harm portability with no discernable benefit.  Using main declared as
returning void is one of the classic examples.




This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.