Skip to main content

CSC 282.01, Class 08: Exploring a C Project

Overview

  • Preliminaries
    • Notes and news
    • Upcoming work
  • Review of components of a typical project
  • Building the Makefile
  • Specifying the interface
  • Writing tests
  • Implementation strategies
  • Building libraries
  • Writing a utility

News / Etc.

  • I would have liked to have seen more of you work on the project (or at least ask questions about it).
  • We will continue the project over break. Please have code ready then.

Upcoming work

  • Finish the Arbitrarily Large Integers / Arbitrary Precision Integers / Arbitrarily Long Integers project.
  • Read about C macros (distributed over break)

Good things to do

  • Singers concerts.
  • Baseball games.
  • Ultimate matches.

Review of components of a typical library project

  • Makefile - Specifies how to build things.
  • Documentation
    • README.md - Overall view of the project
    • DEVELOPER.md - Internal implementation issues
    • MANIFEST.md - List of files and purpose
  • .h files - specify interfaces and more
    • interface: types, procedures, constants, macros
  • Black box tests! (Don’t pay attention to internals)
  • Primary code for the library
    • alint.c - All of the library routines or
    • alint-int.c - Parse/unparse integers
    • alint-double.c - Parse/unparse double
    • alint-string.c - Parse/unparse string
    • alint-math.c - Guess
  • Clear box tests! Get code coverage.
  • Sample application built with the library

Critiques

  • Don’t add files with git add .. Add them individually.

Building the Makefile

What should the Makefile look like?

  • Settings
  • Standard targets
  • Additional dependencies
  • Anything else of use

Specifying the interface

Question: What does this mean?

typedef struct ALInt ALInt;

We will eventually create a struct called struct ALInt. We want to use ALInt as an alias for struct ALInt.

Writing tests

Implementation strategies

  • Linked list.
  • Expandable array.
  • Array with size.
  • Array with terminator.

Building libraries

  • See PMG

Writing a utility

  • Calculator (RPN)