RE: LuaJIT2.1-alpha question

  • From: "Maynard, Ed" <Ed.Maynard@xxxxxxxxxxxxxxxx>
  • To: "luajit@xxxxxxxxxxxxx" <luajit@xxxxxxxxxxxxx>
  • Date: Fri, 10 Oct 2014 18:35:56 +0000

The 2.0.3 version complains about the redefinition as well. Bad memory on my 
part. This is the output from 2.1 alpha:

Lua file:

ffi = require("ffi")
local defs = require("mapcdefs") -- this has the cdef statement in it
local hdr = ffi.new("C_mapping_header_t", {})

LuaJIT output:

luajit2.1->dofile("process_mapping.lua")
.\mapcdefs.lua:95: attempt to redefine 'mapping_header_t' at line 8
stack traceback:
        [C]: in function 'cdef'
        .\mapcdefs.lua:95: in main chunk
        [C]: in function 'require'
        process_mapping.lua:5: in main chunk
        [C]: in function 'dofile'
        stdin:1: in main chunk
        [C]: at 0x00862190

-----Original Message-----
From: luajit-bounce@xxxxxxxxxxxxx [mailto:luajit-bounce@xxxxxxxxxxxxx] On 
Behalf Of Geoff Leyland
Sent: Thursday, October 9, 2014 5:29 PM
To: luajit@xxxxxxxxxxxxx
Subject: Re: LuaJIT2.1-alpha question

On 10/10/2014, at 12:18 pm, Maynard, Ed <Ed.Maynard@xxxxxxxxxxxxxxxx> wrote:

> In the meantime, it appears that this is a well-known issue (redefinition of 
> C structures) without a built-in solution other than creating a new instance 
> of Lua (akin to exit and restart). It also appears that there is no ready way 
> to evaluate whether a variable has been declared or not - no table to look 
> through.

Can you just stick the cdefs into a separate file and require it?  If C 
structure definitions are being remembered, surely package.loaded is being 
remembered as well?
This message and any attachments may be a confidential attorney-client 
communication or otherwise be privileged and confidential. If you are not the 
intended recipient, any review, distribution or copying of this transmittal is 
prohibited. If you have received this transmittal in error, please reply by 
e-mail and delete this message and all attachments.

Other related posts: