External C-Code (.c file) misses #defined values

BlitzMax Forums/BlitzMax Programming/External C-Code (.c file) misses #defined values

Derron(Posted 2012) [#1]
I copied the MaxLua-implementation and extended it for my uses (more oop, limit read/write access to objects/fields, automatic usage of Getters/Setters if possible).

instead of "lua_object.c" I used a copy of the file named "basefunctions_lua.c".

Compilation in normal (+normal debug) works as expected.
Compilation in threaded mode ends with an LD error

./bmk makeapp -x -r -h 
...
Compiling:basefunctions_lua.bmx
...
basefunctions_lua.c.release.mt.linux.x86.o: In function `lua_gcobject':
basefunctions_lua.c:(.text+0xa0): undefined reference to `bbGCFree'
collect2: ld gab 1 als Ende-Status zurück
Build Error: Failed to link 


bbGCFree is only available if compiled in "normal" mode as else a different Method to clean orphans is used (see brl.mod/blitz_gc.h)

bbGCFree is used here (lua_object.c in brl.mod/maxlua.mod):
void lua_gcobject( lua_State *L ){
	BBObject *obj=lua_unboxobject( L,1 );
	BBRELEASE( obj );
}

The Function BBRELEASE is assigned one Function (MS or RC garbage collector) by the blitz_gc.h depending wether "THREADED" is defined or not.

When using "import brl.maxlua" the lua_gcobject is not returning errors
When using my lua-class (remember - it is a copy with some extensions) the error is there. My lua-class is also imported, not included.


ATM I ended up using

?threaded
Import "basefunctions_lua_threaded.c"
?not threaded
Import "basefunctions_lua.c"
?
Extern
	Function lua_boxobject( L:Byte Ptr,obj:Object )
	Function lua_unboxobject:Object( L:Byte Ptr,index:Int)
	Function lua_pushlightobject( L:Byte Ptr,obj:Object )
	Function lua_tolightobject:Object( L:Byte Ptr,index:Int )
	Function lua_gcobject( L:Byte Ptr )
End Extern


the difference between both files is just:
#ifndef THREADED
	#define THREADED
#endif

at the begin of the "basefunctions_lua_threaded.c"



Is there a way to avoid this hassle ?

bye
Ron

Last edited 2012


Derron(Posted 2012) [#2]
Hmm somehow the display of posting dates in the forum + their display order gone wrong.

Still looking for ideads or possibilities to circumvent this problem more elegant than with using an additional file.

bye
Ron


Derron(Posted 2012) [#3]
Hmm Skidracer answered but post is not visible?






Think there is something odd with the forums database


bye
Ron


edit: even after post, total postcounter (of that thread) increased to 4 (with 3 posts) ... the board normally recounts that value if a kind of cache is enabled... strange.

Last edited 2012


Derron(Posted 2012) [#4]
Sorry for bumping but the problem is still existing (and the post count is wrong too).

So if skidracer had given an answer which is now missing - what have you written?

bye
Ron


Zeke(Posted 2012) [#5]
i'm not sure what skid said, but forget MaxLua, and use Lugi

http://github.com/nilium/lugi.mod/


Derron(Posted 2012) [#6]
I don't like the idea of precompiling to get glue code - I do not work in a single-user-dev environment.
Thats why adding Metatags to decide what lua can do with blitzmax objects was a better way for me to.

What is more important than the descision "lugi or not" is the error I get (it should be kind of independend from maxlua).


bye
Ron


Derron(Posted 2014) [#7]
Sorry for bumping that old thread - but the original question stays unsolved.

I just had to repeat the same step for the extended reflection.bmx provided.
Means opening up that reflection.bmx and replace

import "reflection.cpp"

with

?threaded
Import "reflection_threaded.cpp"
?not threaded
Import "reflection.cpp"
?


The only difference between that both files is:
#ifndef THREADED
#define THREADED
#endif

at the top of the reflection_threaded.cpp


Is there a way to circumvent this?


Derron(Posted 2014) [#8]
Another bump - problem is still occurent.

Someone with the right mood to help this days?


bye
Ron


Brucey(Posted 2014) [#9]
Hallo :^)

So you are saying it works with the default code but not with your modified code?


Derron(Posted 2014) [#10]
The default code is from a module - so it gets the information during module compilation.

Just try to use the threaded part of the reflection as normal source code you "import" (import "bla.bmx")


bye
Ron