Coan is a software engineering tool for analysing preprocessor-based configurations of C or C++ source code. Its principal use is to simplify a body of source code by eliminating any parts that are redundant with respect to a specified configuration. Dead code removal is an application of this sort.

Coan is most useful to developers of constantly evolving products with large code bases, where preprocessor definitions and #if-directives are used differentiate progressive releases or parallel variants of the product. In these settings the upkeep of the product's configuration tree can become difficult and the incidence of configuration-related defects can become costly. (The side-panels on these pages illustrate how preprocessor-encrusted production code can get.) Coan can largely automate the maintenance of preprocessor-based configurations and the investigation of configuration-related questions. More...

Latest News

  • 2014-09-16 Coan v6.0.1 release
  • What's new?
    • This patch release corrects minor autotooling bugs in the coan test-harness. There are no changes to the coan executable apart from the version it reports.
  • 2014-08-25 Coan v6.0 release
  • What's new?
    • This feature release is the most extensive since coan 4.0:
      • Lexical scanning and expression parsing are re-written much more efficiently, enabling coan 6.0 to process input on average about twice as fast as coan 5.2
      • Macro-expansion code is rewritten from scratch to cope robustly with function-like macro expansions for the first time.
      • The --evalsyms option of the symbols command was of little investigative use. It is removed and a new option --expand is introduced. --expand reports the full macro expansion of a symbol invocation, and the integer to which it evaluates, if any.
      • The --explain option of the symbols command is radically reworked to report the successive steps of a macro expansion.
      • The --once option is removed and replaced by two new options --once-only and --once-per-file. The former is equivalent to the old --once. The latter causes each distinct reported item to be reported just once per input file.
      • An informational diagnostic is now issued whenever a #define or #undef directive retrospectively affects the meaning of previously defined symbols, e.g. if #define BAR 1 is encountered after #define FOO BAR, or when the commandline option -DFOO=BAR is in effect.
      • The alternative operator keywords, and, or, not, etc. are now recognized.
      • The symbols command now always reports the provenance of a reported symbol:
        • configured global, i.e. by a commandline -D or -U option
        • configured transient, i.e. by an in-source #define or #undef directive
        • unconfigured, i.e. neither of the above
    • New binary packages are made for:-
      • Centos 7
      • Fedora 20
      • RedHat 7
      • OpenSUSE 13.1
      • Ubuntu 13.10
      • Ubuntu 14.04
    • Binary packages are no longer made for:-
      • Centos 6
      • RedHat 6
      • OpenSUSE 12.1
      • SUSE Linux Enterprise
      • Debian 6.0
      • Ubuntu 12.04
    • All (16) open bugs on v5.2 are closed
    • A complete listing of the changes can be found in the changelog.
  • 2013-09-07 Coan v5.2 release
  • What's new?
    • This feature release adds two new options to the symbols command that analyses the processor macros used in the scanned code.
      • The select option lets you specify a set of symbols or wildcard prefixes that will restrict coan's reporting to matching symbols.
      • The explain option directs coan to "backtrace" the expansion of each macro S that is reported by recursively reporting the expansion of each macro that is expanded in expanding S.
    • Apple OS X is now supported by the source tarball. (OS X binaries are not provided).
    • All (7) open bugs on v5.1.2 are closed
    • A complete listing of the changes can be found in the changelog.

Supported Platforms

Coan 6.0 has been built and tested successfully on the following platforms:

  • CentOS Linux 7:- x86, x86_64
  • Debian Linux 7.0:- x86, x86_64
  • Fedora Linux 17, 18, 19, 20 :- x86, x86_64
  • openSUSE Linux 12.2, 12.3, 13.1:- x86, x86_64
  • Redhat Enterprise Linux 7:- x86_64
  • Ubuntu Linux 12.10, 13.04, 13.10, 14.04:- x86, x86_64
  • Microsoft Windows Windows 7:- x86_64

There is a good chance that Coan will build from source on a system that provides the GCC C++, GNU autotools tools and Python. However it will not peform arithmetic operations correctly on PowerPC, ARM or other big-endian architecture.

Authorship, Copyright & License

  • The author and maintainer of Coan is Mike Kinghan, Some fundamental elements of Coan are derived from Tony Finch's version of Unifdef.
  • Coan is copyright © 2004 - 2006 Symbian Software Ltd., © 2007 - 2014 Mike Kinghan, except where otherwise asserted by copyright notices within the source files. Some source files that vitally depend on cribs from the work of Tony Finch retain his copyright notice.
  • Coan is derived from BSD licensed code and is released under the New BSD License.

Dedication

Coan is dedicated to the memory of Altan Walker, nee Vaughan Kinghan, 1964 - 2007.