lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2012/3/8 Daniel Cegiełka <daniel.cegielka@gmail.com>:
> Thx a lot! It works.
>
> Daniel
>
>
>
> 2012/3/8 Benjamin von Ardenne <benjamin.von.ardenne@gmail.com>
>>
>> Omit the local because ffi is only valid for this one line in
>> interactive-mode and you should be fine.
>>
>> On Thu, Mar 8, 2012 at 5:46 PM, Daniel Cegiełka
>> <daniel.cegielka@gmail.com> wrote:
>> > Hi,
>> > I try to run FFI example: http://luajit.org/ext_ffi.html
>> >
>> > Does anyone have an idea of what I'm doing wrong.
>> >
>> > danice@entropy ~ $ luajit
>> > LuaJIT 2.0.0-beta9 -- Copyright (C) 2005-2011 Mike
>> > Pall. http://luajit.org/
>> > JIT: ON CMOV SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc fuse
>> >> local ffi = require("ffi")
>> >> ffi.cdef[[
>> >>> int printf(const char *fmt, ...);
>> >>> ]]
>> > stdin:1: attempt to index global 'ffi' (a nil value)
>> > stack traceback:
>> >         stdin:1: in main chunk
>> >         [C]: ?
>> >>
>> >
>> > best regards,
>> > Daniel
>> >
>> >
>>
>
Alternatively you can wrap your code in a do block.
LuaJIT 2.0.0-beta8 -- Copyright (C) 2005-2011 Mike Pall. http://luajit.org/
JIT: ON CMOV SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc fuse
> do
>> local ffi=require'ffi'
>> ffi.cdef'int printf(char const *fmt,...);'
>> print(ffi)
>> end
table: 0x0004c698