[cfe-dev] Extending C to support non power of two bit variables

Eli Friedman eli.friedman at gmail.com
Sat Jun 14 21:48:12 PDT 2008

On Sat, Jun 14, 2008 at 9:13 PM, Nadav Rotem <nadav256 at gmail.com> wrote:
> Thank you Eli!
> You really helped me in directing me to the right places.

You're welcome.

> I hoped there
> was an easier way to do this. Would such a patch be accepted into
> clang ? It seems like if I were to implement non power of two variables
> I would have to maintain a fork of clang.

I think it would be accepted; for the attribute itself, it seems
potentially useful, and the attribute implementation itself isn't very
much code.  Having the types around would be useful for other things,
like an implementation of the mode attribute that isn't dependent on
the target having appropriate regular integer types.

A couple of small things which I just thought of: one, I'm not sure
whether the LLVM arbitrary-width integers do exactly what you expect
in terms of data layout.  The way it works is that the data layout is
the same as that of the next-largest integer type (see
http://llvm.org/docs/LangRef.html#datalayout).  The other thing is
something I didn't quite state explicitly: because of the C integer
promotion rules, an int5 will be immediately promoted to int whenever
its value is used.

And a minor side-note: you forgot to CC the list on your reply.  Make
sure to click reply-to-all rather than reply when replying to a
mailing list message.


More information about the cfe-dev mailing list