Re: Support for 64-bit constants (uint64_t for example in code)?

  • From: Alex <initrd.gz@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sun, 14 Oct 2012 18:06:40 -0400

Well, for example, some OpenGL extensions use longs for some things. I
could parse the constants and put them into a Lua table declaration, but
that would mean yet another library prefix (`gl.glSomeFunc()` and
`glconst.GL_SOME_CONST`, I guess it wouldn't be that bad), and I don't know
if they would be converted into constants by the JIT compiled (though I'm
not really concerned about that).

On Sun, Oct 14, 2012 at 7:45 AM, Mike Pall <mike-1210@xxxxxxxxxx> wrote:

> Dimiter 'malkia' Stanev wrote:
> > How hard would it be to have support for 64-bit constants in code,
> > e.g. for this to work:
> >
> > ffi.cdef[[
> >   const uint64_t test123 = 123;
> > ]]
> >
> > I don't require the actual literal value (123 that is) be to 64-bit,
> > but the actual value must be.
>
> Moderately complicated, because all places that internally deal
> with C constants need to be changed. And the C expression
> evaluator needs to learn more coercion rules.
>
> But what about:
>
>   local test123 = 123ULL
>
> If it's an upvalue to a function then it gets constified. This is
> as good as writing 123ULL literally.
>
> --Mike
>
>

Other related posts: