lua-users home
lua-l archive

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


Some more information on this problem to digest. I tried using a
stripped down C code block in Simulink and a different compiler as
well (MSVC 6). Shown below is my relevant C code:
----------------------------------------
/* Stuff ... */
...

#include "lua.h"
#include "lauxlib.h"
#include "luaconf.h"

...
/* Stuff ... proceed into function */

  lua_State* L= 0;
  if (L == 0) {
    L = lua_open();
    luaL_openlibs(L);
    if (luaL_loadfile(L,"dummy.lua")||lua_pcall(L,0,0,0))
      printf("*** ERROR: bad load of dummy.lua\n");
  }

...

dummy.lua has the following:
-------------------------------------
print('hello')
io.write('hello')
print('hello')
f=assert(io.open('dummy.out','w'))
f:write('hello')
f:close()

Output from dummy.lua exercised by the lua interpreter:
-----------------------------------
hello
hellohello

and dummy.out contains 'hello' as well

Output from dummy.lua called from my C code:
-----------------------------------
hello
hello

...and then the dialog comes up: dummy.exe has encountered a problem
and needs to close. Blah blah blah. Please tell Microsoft about this
problem.

dummy.out does not exist, as the execution never made it to that part
of my code.

Further information: I linked against the MinGW-created liblua.a to
get my function exports.

My apologies for the somewhat-long post, but I'm more than a little perplexed.
-- 
Keith Pimmel