Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ SMAUG ➜ Lua ➜ Trouble with implicit declarations of lua things

Trouble with implicit declarations of lua things

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Aiseant   (33 posts)  Bio
Date Tue 22 Feb 2011 08:32 AM (UTC)
Message
Hello world

I'm also trying to put Lua in a C based mud, and got a bunch of things like :
"In file included from lua.h:17,
from lauxlib.c:23:
lauxlib.h:37: error: expected specifier-qualifier-list before
or kinda
warning: implicit declaration of function luaL_optlstring

To me, it sounds like a problem with the link with liblua.a, but i'm not sure.

I included lua.h (5.1.4), currently including luaconf.h lauxlib.h and lualib.h, a makefile with L_FLAGS = $(PROF) liblua.a -lm and $(CC) $(L_FLAGS) -o ../../blabla/bin/swr $(O_FILES) $(L_FLAGS) -lm -lcrypt

and ... I'm lost, hehe :)

Thanks for your time.
Regards
Aiseant
Top

Posted by Nick Gammon   Australia  (23,097 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 22 Feb 2011 09:54 AM (UTC)
Message
Aiseant said:

I'm also trying to put Lua in a C based mud, and got a bunch of things like :


Can you post this "bunch of things"? In particular from the start of the errors.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,097 posts)  Bio   Forum Administrator
Date Reply #2 on Tue 22 Feb 2011 09:56 AM (UTC)
Message
Is that really what it says? Is "or kinda" in the source file?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Aiseant   (33 posts)  Bio
Date Reply #3 on Tue 22 Feb 2011 10:30 AM (UTC)

Amended on Tue 22 Feb 2011 10:40 AM (UTC) by Aiseant

Message
Ok, there is the bunch :



comm.c: In function 'nanny':
comm.c:1999: warning: implicit declaration of function 'open_lua'
comm.c:2006: warning: implicit declaration of function 'call_lua'
db.c: In function 'free_char':
db.c:2010: warning: implicit declaration of function 'close_lua'


update.c: In function 'char_update':
update.c:1192: warning: implicit declaration of function 'call_lua'

In file included from lua.h:17,
from lauxlib.c:23:
lauxlib.h:37: error: expected specifier-qualifier-list before 'lua_CFunction'
lauxlib.h:42: error: expected ')' before '*' token
...etc...
lauxlib.h:82: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
lauxlib.h:85: error: expected ')' before '*' token
lauxlib.h:88: error: expected ')' before '*' token
lauxlib.h:132: error: expected specifier-qualifier-list before 'lua_State'
lauxlib.h:145: error: expected ')' before '*' token
In file included from lua.h:18,
from lauxlib.c:23:
lualib.h:19: error: expected ')' before '*' token
...etc...
lauxlib.c: In function 'luaL_argerror':
lauxlib.c:46: warning: implicit declaration of function 'luaL_error'
lauxlib.c: At top level:
lauxlib.c:86: error: conflicting types for 'luaL_error'
lauxlib.c:86: note: a parameter list with an ellipsis can't match an empty parameter name list declaration
lauxlib.c:46: note: previous implicit declaration of 'luaL_error' was here
lauxlib.c: In function 'luaL_checkoption':
lauxlib.c:101: warning: implicit declaration of function 'luaL_optlstring'
lauxlib.c:102: warning: implicit declaration of function 'luaL_checklstring'
lauxlib.c:102: warning: initialization makes pointer from integer without a cast
lauxlib.c: At top level:
lauxlib.c:158: error: conflicting types for 'luaL_checklstring'
lauxlib.c:102: note: previous implicit declaration of 'luaL_checklstring' was here
lauxlib.c:165: error: conflicting types for 'luaL_optlstring'
lauxlib.c:101: note: previous implicit declaration of 'luaL_optlstring' was here
lauxlib.c: In function 'luaL_register':
lauxlib.c:231: warning: implicit declaration of function 'luaL_openlib'
lauxlib.c: At top level:
lauxlib.c:242: warning: conflicting types for 'luaL_openlib'
lauxlib.c:231: note: previous implicit declaration of 'luaL_openlib' was here
lauxlib.c: In function 'luaL_openlib':
lauxlib.c:247: warning: implicit declaration of function 'luaL_findtable'
lauxlib.c:252: warning: comparison between pointer and integer
lauxlib.c:264: error: 'luaL_Reg' has no member named 'func'
lauxlib.c: In function 'luaL_gsub':
lauxlib.c:345: warning: implicit declaration of function 'luaL_buffinit'
lauxlib.c: At top level:
lauxlib.c:357: error: conflicting types for 'luaL_findtable'
lauxlib.c:247: note: previous implicit declaration of 'luaL_findtable' was here
lauxlib.c: In function 'emptybuffer':
lauxlib.c:399: error: 'luaL_Buffer' has no member named 'buffer'
lauxlib.c:402: error: 'luaL_Buffer' has no member named 'L'
...etc...
lauxlib.c: At top level:
lauxlib.c:472: warning: conflicting types for 'luaL_buffinit'
lauxlib.c:345: note: previous implicit declaration of 'luaL_buffinit' was here
lauxlib.c: In function 'luaL_buffinit':
lauxlib.c:473: error: 'luaL_Buffer' has no member named 'L'
lauxlib.c:474: error: 'luaL_Buffer' has no member named 'buffer'
make[1]: *** [lauxlib.o] Erreur 1
make[1]: quittant le repertoire /home/parent/Telechargements/netrunners_viv/src
make: *** [all] Erreur 2

The kinda was because I got a lot of warning: implicit declaration of function lua_something.

...etc... = the same message again and again

the 'expected specifier-qualifier-list before 'lua_CFunction'' make me think that I linked something wrongly , since it doesn't seems to know what a lua_CFunction is.

Sorry for my froggy english
Top

Posted by Aiseant   (33 posts)  Bio
Date Reply #4 on Tue 22 Feb 2011 12:48 PM (UTC)

Amended on Tue 22 Feb 2011 04:15 PM (UTC) by Aiseant

Message
okay .... you cannot see what you have in front of you ...
When I stopped being a moron, it stopped to be so buggy :)
While posting, I realize that my errors was moslty into a lauxlib.c, which have absolutly nothing to do in my makefile. Sorry for disturbing.


So in my comm.c, I reattached the lua_scripting.c, which is calling lua.h, which is calling luaconf.h, lauxlib.h and lualib.h. (pfui)
and ...
lauxlib.h:37: error: expected specifier-qualifier-list before lua_CFunction is coming back (first error, but
I've got the same problem with lua_State right after)
I really need to sort out what is going where between mud.h, comm.c, lua.h, lua_scripting.c, lauxlib.h, luaconf.h, lualib.h.

I think I found the way to do it, however, I still have problems with LUA_STARTUP.

I found this
Quote:
+ #define LUA_STARTUP LUA_DIR "startup.lua" /* script initialization */
in the thread How to add Lua scripting to SMAUG

I copied what Gammon proposed, however, I don't exactly know what I've to put in this startup.lua file.


Do I have to put in any function I made in lua ? I thought that I could make a new .lua file for each of them (java-like, but I like it).


Last known problem : a small thing with ll_loadfunc,dlsym,dlopen etc but I think the computer I'm on isn't up to date about C libraries, will try on another

ps: do you know that the forum glitches when you try to put a strange caracter, like a french accent for instance :)
Top

Posted by Nick Gammon   Australia  (23,097 posts)  Bio   Forum Administrator
Date Reply #5 on Tue 22 Feb 2011 07:57 PM (UTC)
Message
Yes, sorry about the forum. It started doing that a little while back. Not sure why.


The Lua startup file (which is called by open_lua) should contain the stuff you want to add with Lua scripting. An example is half-way down the page:

http://www.gammon.com.au/forum/?id=8000

(Where it says "Below is a minimal startup.lua file ...").

Of course, you can modularize that (with dofile or similar).

As an example, this minimal function:


function entered_room (vnum)
end -- entered_room


You could change this to:


function entered_room (vnum)

-- get info about current character
local info = character_info ()

  if info.name == "Nick" then
    send ("Hi Nick, I see you have changed rooms!")
    send ("You are now in room ", vnum)
  end -- if Nick

end -- entered_room


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Aiseant   (33 posts)  Bio
Date Reply #6 on Tue 22 Feb 2011 08:05 PM (UTC)

Amended on Tue 22 Feb 2011 08:06 PM (UTC) by Aiseant

Message
Ok, I figured this out and tried with my own functions, but having confirmation is good.
Thanks a lot for helping (and letting me talking and debug in public, if you watched my posts between my several 'edits'), and for the very good 'How to add Lua scripting to SMAUG' thread, very helpful.

Lua seems to be working, but I'm sure you'll have news of this very soon in another thread ;-)

I intend to progressively transform my C based mud into a full Lua, I think this will take time but I'm convinced that it is a very powerful tool and I'm sure the game will gain a lot with it. I've joined today the wonderful world of Lua :-)


ps: no problem about french caracteres, just had a hard time understanding why my posts was cut in half
Top

Posted by Nick Gammon   Australia  (23,097 posts)  Bio   Forum Administrator
Date Reply #7 on Tue 22 Feb 2011 08:05 PM (UTC)
Message
Aiseant said:


the 'expected specifier-qualifier-list before 'lua_CFunction'' make me think that I linked something wrongly , since it doesn't seems to know what a lua_CFunction is.


lua_CFunction is declared in lua.h. It seems strange it doesn't find that.

Line 53 in my copy:


typedef int (*lua_CFunction) (lua_State *L);


What do you have in the first 20 lines of lua.h? In mine, line 17 is empty.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Aiseant   (33 posts)  Bio
Date Reply #8 on Tue 22 Feb 2011 08:08 PM (UTC)
Message
As I said, the includes was in the wrong order (I presume), lua_CFunction was well defined in lua.h.

One solution is to include evrything everywhere and ask gcc to clean it, the other is taking time to read the whole thing, take a good breath and do it again from scratch (eventually both)
Top

Posted by Aiseant   (33 posts)  Bio
Date Reply #9 on Tue 22 Feb 2011 09:11 PM (UTC)

Amended on Tue 22 Feb 2011 09:17 PM (UTC) by Aiseant

Message
And as I also said, seems to work :D
I think I'll open another thread, something like "helping me to build lua on sand bases"...

Just a last question before that:
My first try is with
require "wait"

and returns

Error loading Lua startup file:
 ../src/startup.lua:15: module 'wait' not found:
	no field package.preload['wait']
	no file './wait.lua'
	no file '/usr/local/share/lua/5.1/wait.lua'
	no file '/usr/local/share/lua/5.1/wait/init.lua'
	no file '/usr/local/lib/lua/5.1/wait.lua'
	no file '/usr/local/lib/lua/5.1/wait/init.lua'
	no file './wait.so'
	no file '/usr/local/lib/lua/5.1/wait.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
	[C]: in function 'require'
	../src/startup.lua:15: in main chunk

However, wait.lua is in the same directory than startup.lua (ie there is a './wait.lua' file)
What I'm missing ?

I can make this 'require wait' and then use wait.wpause(n) in my own function, right ?
something like

require "wait"


function test (arg)



  if arg == "a" then 

	   mud.send_to_char ("a")
	   wait.wpause(1)
	   return
  end

   if arg == "b" then 
	   mud.send_to_char ("b")
	   wait.wpause(1)
	   return
  end

end
Top

Posted by Nick Gammon   Australia  (23,097 posts)  Bio   Forum Administrator
Date Reply #10 on Tue 22 Feb 2011 10:52 PM (UTC)
Message
You may have wait.lua in the same directory as startup.lua, but that isn't where it is looking.

Your current directory is "area", right? And you can see from here:


 ../src/startup.lua:15: module 'wait' not found:


The file startup.lua is in "src" not "area". But it is looking in the current directory not the src directory.

In any case, if you are using wait.lua from the MUSHclient distribution, that won't work. That relies on MUSHclient timers to make it work, and you are running Smaug, not MUSHclient.

To implement pauses you really need to have something happen in your script periodically (like char_update) and in that decide if you want to send another message.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Aiseant   (33 posts)  Bio
Date Reply #11 on Wed 23 Feb 2011 02:25 PM (UTC)

Amended on Thu 24 Feb 2011 10:38 AM (UTC) by Aiseant

Message
ok ... I thought about this and very logically, copied the wait.lua in the same directory as ... my exe \o/

As my primary problem is solved and what I have now is my own absence of knowledge about Lua, I started another thread, more appropriate, here : http://www.gammon.com.au/forum/bbshowpost.php

Many thanks for helping me solve those things.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


35,731 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.