[bitc-dev] Conditional compilation
Jonathan S. Shapiro
shap at eros-os.com
Thu Jul 17 15:54:45 CDT 2008
On Thu, 2008-07-17 at 13:39 -0700, Eric Rannaud wrote:
> The last case may be more interesting, because I think you need support
> at the language level.
>
> int userspace_ok(void);
> #ifdef KERNEL
> int restricted(void);
> #endif
> int userspace_ok2(void);
>
> One could argue that it's best to split the interface in two. I'm not
> sure it makes things clearer to follow, though.
Yes. I deliberately left this out of BitC, because I was hoping to avoid
an explosion of compile configurations that would have to be avoided.
Now that I am looking seriously at automatic conversion of C code to
BitC code, I'm being forced to reconsider my view.
Your earlier comment about if and compile-time constants applies here as
well (at least partially). The thing that makes CPP such a nightmare is
not the conditional compilation per se, but the fact that the
substitutions performed by CPP are not performed over lexically "clean"
units.
I've actually been contemplating (with reluctance) a top-level
conditional compilation construct using term expressions and some form
of top-level conditional control, but in abstract I think that the case
you are giving above really is better handled by a second interface.
shap
More information about the bitc-dev
mailing list