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

  • From: Dimter 'malkia' Stanev <malkia@xxxxxxxxx>
  • To: "luajit@xxxxxxxxxxxxx" <luajit@xxxxxxxxxxxxx>
  • Date: Sun, 14 Oct 2012 22:31:37 -0700

No problem Mike.

This came as I'm working on somewhat more complete WinAPI ffi binding.
All values themselves are 32-bit, but I thought for better clarity to assign 
them to their type (cons static uint64_t enum1 = value1) - I will simply move 
back to use enums in this case (most of these were preprocessor literals in the 
first place)

Thanks,
Dimiter 'malkia' Stanev

Sent from my iPad

On Oct 14, 2012, at 4: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: