|
Currently I'm making bindings for libevent2 (2.0). We could do it like they do:On Wed, Mar 26, 2014 at 8:06 PM, Rena <hyperhacker@gmail.com> wrote:
> On Wed, Mar 26, 2014 at 4:41 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>>
>> 2014-03-26 10:28 GMT+02:00 steve donovan <steve.j.donovan@gmail.com>:
>> > On Wed, Mar 26, 2014 at 9:57 AM, Sean Conner <sean@conman.org> wrote:
>> >>
>> >> I thought something like:
>> >>
>> >> #!/usr/bin/env lua -e "if _VERSION ~= 'Lua 5.3' then print('bad lua')
>> >> return end" -
>> >>
>> >> would work, but apparently not ...
>> >
>> > But
>> >
>> > lua -e "if _VERSION ~= 'Lua 5.3' then print('bad lua'); os.exit(1) end"
>> > -
>> >
>> > does work, at least on Windows.
>>
>> Is that useful? Consider this variation:
>>
>> lua53 -e "if _VERSION ~= 'Lua 5.3' then print('Somebody has gained
>> malicious access to my computer'); os.exit(1) end"
>>
>
> The trouble with this solution (and several other examples) is that it
> requires *exactly* Lua 5.3, not 5.3 or greater.
>
> --
> Sent from my Game Boy.
#if defined(_EVENT_NUMERIC_VERSION) && _EVENT_NUMERIC_VERSION >= 0x2000000
It's lucky we have hex literals. For "formal" modules in Lua we'd have:
_NAME = 'Lua'
_VERSION = '5.3'
_VERSION_NUMBER = 0x05030000
Basically 4 octets; a major, minor, revision, and release field.
A version of "5.3.1-r7" would be: 0x05030107
You could then do:
if _VERSION_NUMBER < 0x05030000 then
error('we have a problem :(')
end
~ just thought I'd toss this idea in ~