lua-users home
lua-l archive

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


Quoting Jon Kleiser on 98 11 12 23:20:
>I'm trying to put together a small (68K) Mac C application, using
>lualib31_68K and CodeWarrior 11. I managed to execute some plain Lua
>scripts, but I also need to write a few new functions in C, to be called
>from Lua. However, when I launch my application and the luaL_openlib(...)
>gets executed, I get:
>
>   "API error - attempt to push a NULL Cfunction"
>
>I'd be glad if anybody could suggest what I'm doing wrong.

Your code compiled and ran without problems on a CodeWarrior Pro 3 
installation. I've just commented out references to the "IPNameToAddress" 
function that is probably defined elsewhere:

static void ez_IPNameToAddr (void)
{
        OSErr   err;
        ip_addr addr=0;

        /*err = IPNameToAddress( luaL_check_string(1), &addr );*/
        SysBeep( luaL_check_number(1) ); /* it beeps very well */
       /* if (err != noErr) {
                addr = 0;
        }*/
        lua_pushnumber( addr );
}

I don't have CW 11 installed anymore, so I can't check if this is some 
sort of incompatibility between the two Warriors [the lib was made with 
CW Pro3], but if anything else fails, you may try to recompile the entire 
Lua lib in your environment. Create a blank empty project, add the files 
listed below, and set the project target settings to Project Type: 
Library; 	Filename: lualib31_68K.

Regards,

Claudio.

>"Jo no creo en bruxas, pero que las hay las hay"
Friday 13th is a good day for witch hunting.


Files from the full Lua 3.1 distribution to include in a Mac LuaLib 
project:

Includes:
	lauxlib.h
	lua.h
	luadebug.h
	lualib.h

Sources:	
	lapi.c
	lapi.h
	lauxlib.c
	lbuffer.c
	lbuiltin.c
	lbuiltin.h
	ldo.c
	ldo.h
	lfunc.c
	lfunc.h
	lgc.c
	lgc.h
	llex.c
	llex.h
	lmem.c
	lmem.h
	lobject.c
	lobject.h
	lopcodes.h
	lparser.c
	lparser.h
	lstate.c
	lstate.h
	lstring.c
	lstring.h
	ltable.c
	ltable.h
	ltm.c
	ltm.h
	lundump.c
	lundump.h
	lvm.c
	lvm.h
	lzio.c
	lzio.h
	
Lib Sources:
	liolib.c
	lmathlib.c
	lstrlib.c