[ANN] Design by Contract for C

I am pleased to announce the first public release of DBC for C - a C preprocessor that generates contract testing code and documentation from DBC tags embedded in C comments. Here is an example:
/**
   pre: i >= 0
   pre: i < array->length
   post: array->array[i] == elem
  */
void
Array_put(T array, long i, void *elem)
{
   array->array[i] = elem;
}

DBC for C supports preconditions, postconditions, invariants and some iterating operators (forall, exists). Also DBC for C can generate Doxygen documentation from contracts. For more information take a look at this article:
http://www.onlamp.com/pub/a/onlamp/2004/10/28/design_by_contract_in_c.html
(also featured on the front page of onlamp.com :slight_smile:

Project Wiki:
http://dbc.rubyforge.org/wiki/wiki.pl
Download page:
http://rubyforge.org/frs/?group_id=354

The DBC for C source package contains an example library, found in the test_app directory.

DBC for C was created with Ruby and Racc.

Many thanks to Marcel Molina Jr. for proof reading the article, Daniel Berger for submitting the first bug report, and Dave Thomas for writing the book that got this started.

Enjoy!

-Charlie

PS. Feed back is welcome.

"Charles Mills" <cmills@freeshell.org> schrieb im Newsbeitrag
news:E7BDC4FA-29B8-11D9-9E2C-000A95A27A10@freeshell.org...

I am pleased to announce the first public release of DBC for C - a C
preprocessor that generates contract testing code and documentation
from DBC tags embedded in C comments. Here is an example:

DBC for C supports preconditions, postconditions, invariants and some
iterating operators (forall, exists). Also DBC for C can generate
Doxygen documentation from contracts. For more information take a look
at this article:

PS. Feed back is welcome.

Sounds like a great piece of work!

I just wonder: are you really trying to make C safe? Sounds like an
oxymoron... :slight_smile:

Kind regards

    robert

No and certainly DBC for C is not a one-size fits all solution. But, it is very helpful if your doing OO style C programming.

Best,
Charlie

···

On Oct 29, 2004, at 8:13 AM, Robert Klemme wrote:

"Charles Mills" <cmills@freeshell.org> schrieb im Newsbeitrag
news:E7BDC4FA-29B8-11D9-9E2C-000A95A27A10@freeshell.org...

I am pleased to announce the first public release of DBC for C - a C
preprocessor that generates contract testing code and documentation
from DBC tags embedded in C comments. Here is an example:

DBC for C supports preconditions, postconditions, invariants and some
iterating operators (forall, exists). Also DBC for C can generate
Doxygen documentation from contracts. For more information take a look
at this article:

PS. Feed back is welcome.

Sounds like a great piece of work!

I just wonder: are you really trying to make C safe? Sounds like an
oxymoron... :slight_smile: