[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [LuaJIT ffi] Misleading error message?
- From: Thomas Lauer <thomas.lauer@...>
- Date: Sat, 23 Jul 2011 16:07:39 +0100
Mike Pall <mikelu-1107@mike.de> wrote:
> Thomas Lauer wrote:
> > The following code, run under Windows, produces an error message for
> > line 4 which IMHO is misleading at best but more probably spurious?
> >
> > ffi=require('ffi')
> > ffi.cdef('void DebugBreak(void);') -- Any function will do
> > if ffi.C.DebugBreak then print(ffi.C.DebugBreak) end -- OK
> > if ffi.C.DebugBreak~=nil then print(ffi.C.DebugBreak) end
> >
> > luajit.exe: f:\testffi.lua:4: attempt to compare 'void ()' with 'void *'
>
> Well, the error message is correct. You're comparing a function
> with nil (which is treated like a pointer to void here).
Technically you're right. Any competent C programmer will have an idea
what this messages means and where it comes from. However, I assume that
the ffi functions will be used also by people who've not done a lot of C
programming.
> [But note that neither of two conditionals in your code can ever
> be true. Only nil and false are treated as not-true conditions.
I am not sure that I follow. Here, ffi.C.DebugBreak evaluates as true.
The actual code that triggered this mail is somewhat more involved than
the simplified example I gave.
--
cheers thomasl