[bitc-dev] Conditional compilation

Eric Rannaud eric.rannaud at gmail.com
Thu Jul 17 15:54:14 CDT 2008


On Thu, 2008-07-17 at 13:39 -0700, Eric Rannaud wrote:
> Here is a list of use cases for conditional compilation that I've come
> across (note that it includes #ifdef in header files):
> - disabling debug code,
> - feature selection,
> - choosing code path from constants,
> - exposing/hiding interfaces depending on context,

Oh, and there is another case I forget, for which you would need
language support:

struct a {
	int x, y;
#ifdef DEPRECATED_FEATURE /* too go in 2 revisions */
	char c;
#endif
};

Of course, I guess one can do that with type classes. But is it worth
the trouble? And there is no 'deriving' (cf. Haskell) in BitC, is
there? 

I can't think of a way of doing in BitC, without conditional
compilation, the equivalent of

void foo(struct a *a, int p)
{
	a->x = p;
	a->y = 2*p;
#ifdef DEPRECATED_FEATURE
	a->c = '0';
#endif
}

without duplicating at least some code (the point being that the
difference introduced by DEPRECATED_FEATURE is in the definition of the
type 'struct a').

Any idea?




More information about the bitc-dev mailing list