C is a pragmatical, general purpose, block structured, procedural, imperativeprogramming language. C was developed in 1972 by Dennis Ritchie at the Bell Laboratories. It was first intended as a system programming language for the Unix operating system, but has spread to many other platforms and application programming as well. C and its derivations are likely the most often used languages so far for computer chess programming.
Due to explicit pointers (address of a variable or function), C can be considered as a high level assembly language, but has some weak spots in its initial design and implementation, which are addressed in
To be aware of the scalar 64-bit origin of bitboards in computer chess, we use so far a type defined unsigned integer U64 in our C and C++ source snippets. The macro C64 will append a suffix to 64-bit constants as required by some compilers:
typedef unsigned __int64 U64; // for the old microsoft compilers
typedef unsigned long long U64; // supported by MSC 13.00+ and C99
#define C64(constantU64) constantU64##ULL
Pointer
Array
Struct
A structure in C refers to Object composition to encapsulate related scalar datatypes inside one structured item. The size of the structure is the sum of its element sizes. To access the structure elements the dot-operator separates the element from the variable or reference. Pointers require arrow operator.
struct MOVE
{char from;char to;};
...
MOVE m, a, *b;
m.from= square;
...
if( a.from== b->to )
Bitfield
So called Bitfields might be implemented as structure where integer members are declared with explicit bit length specifier from 1 .. 31. However due to portability issues of various C-compilers and platforms concerning bit ordering, padding and eventually the sign, most programmer rely on explicit bitfields to composite and extract sub-items by shift and masks, i.e. in encoding moves.
Union
Variables
Variables are either stored in various memory areas or kept inside processor registers.
A C-Compiler is used to translate the source program, usually ascii-text files with the extension .C, to so called object files, containing machine instructions. A linker binds all the object files together with libraries containing external functions (and data) to build an executable program.
Table of Contents
C is a pragmatical, general purpose, block structured, procedural, imperative programming language. C was developed in 1972 by Dennis Ritchie at the Bell Laboratories. It was first intended as a system programming language for the Unix operating system, but has spread to many other platforms and application programming as well. C and its derivations are likely the most often used languages so far for computer chess programming.
Due to explicit pointers (address of a variable or function), C can be considered as a high level assembly language, but has some weak spots in its initial design and implementation, which are addressed in
Data
Data Types
Primitive Data Types
To be aware of the scalar 64-bit origin of bitboards in computer chess, we use so far a type defined unsigned integer U64 in our C and C++ source snippets. The macro C64 will append a suffix to 64-bit constants as required by some compilers:Pointer
Array
Struct
A structure in C refers to Object composition to encapsulate related scalar datatypes inside one structured item. The size of the structure is the sum of its element sizes. To access the structure elements the dot-operator separates the element from the variable or reference. Pointers require arrow operator.Bitfield
So called Bitfields might be implemented as structure where integer members are declared with explicit bit length specifier from 1 .. 31. However due to portability issues of various C-compilers and platforms concerning bit ordering, padding and eventually the sign, most programmer rely on explicit bitfields to composite and extract sub-items by shift and masks, i.e. in encoding moves.Union
Variables
Variables are either stored in various memory areas or kept inside processor registers.Globals
On the Stack
On the Heap
Register
Instructions
Operations
Arithmetical
Bitwise boolean
Relational
Logical
Functions
Expressions
Control Flow
Goto
If else
Switch case
Function Pointer
For
While
Do while
Preprocessor
Portabilty
Twos' Complement
sizeof
shift
Endianness
Main article EndiannessLibraries
C and C++ Compiler
A C-Compiler is used to translate the source program, usually ascii-text files with the extension .C, to so called object files, containing machine instructions. A linker binds all the object files together with libraries containing external functions (and data) to build an executable program.Books
Publications
Forum Posts
1999
2000 ...
2005 ...
2010 ...
Re: A note for C programmers by Rein Halbersma, CCC, November 28, 2013
2015 ...
External Links
References
Up one Level