Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Why idempotent?

Author: Daniel Clausen

Date: 15:43:16 02/14/00

Go up one level in this thread


Hi

>>#include "search.c"
>>#include "board.c"
>>#include "data.c"
>>#include "eval.c"
>>#include "main.c"

>This may, for reasons that are beyond me (no CS background btw), make
>wintel-centric compilers improve the code generated, but it is _not_ portable,
>and unless I am wrong, it is _not_ standard C.
>
>If someone could clarify this, I would appreciate it.  If by chance I am wrong,
>my appologies Dan.  But it won't compile like this in Codewarror.

As far as I know, the C-language definition doesn't *forbid* to include c-files
directly. The reasons why it didn't compile is prolly one of the following:

1 In your project you should only add the one file containing Dan's funny
  includes. Don't add the other files to the project or you'll end up with
  "duplicate definitions" etc. Just make sure that you'll add the path for
  the rest of the .c files to your project.

2 If you did that it will prolly fail because there are no #ifndef's in
  Tom's header files. Therefore you'll most prolly will end up with msgs
  saying "identifier <whatever> redeclared" and stuff like that.

  To prevent this you can add the following stuff in the header files.

  #ifndef __MYHEADERFILE_H__
  #define __MYHEADERFILE_H__

  <rest of header file>

  #endif /* __MYHEADERFILE_H__ */

  If the same headerfile will be included more than once the #ifndef will
  cause the compiler (or more the preprocessor) to 'ignore' it the 2nd time.

  Note that a lot of people often use _MYHEADERFILE_H_ instead. (only one
  leading/trailing underscore) While this may work fine in most cases, it's
  not nice, since symbols starting with 1 underscore belong to the compilers
  namespace.

Kind regards,
 -sargon




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.