Lecture 7 Demos:

First pass

queens.c, checkboard.c, printboard.c.

The files above are a first attempt to split the N-Queens program up into three separate source files.

To compile the program, we can either compile each of the source files separately,

and link them together into an executable,

Or we can compile and link them all at once.

Splitting the code into separate files provides several key advantages:

But there is a serious problem with these files. Because we naively broke the code up into three files, several of the function calls in main() are now implicitly declared. Implicit declaration means that the compiler does no checking of parameter numbers and types for us.

When we updated the printboard() function call in queens.c to take only a row parameter and forgot to update the corresponding definition in printboard.c, we introduced a critical bug into the program that the compiler will not catch.

This code will compile without warnings or errors, but will core dump on a segmentation fault as soon as the printboard() function is called.

Second Pass.