Incbin bug/limitation

BlitzMax Forums/BlitzMax Programming/Incbin bug/limitation

Curtastic(Posted 2006) [#1]
it says "Incbin can only be used in main program block"
Const incbinning=True
If incbinning Then
Incbin "image\font2.png"


It would be really handy for me to have this fixed. The program takes a long time to compile each time when using incbins. Right now I just rem them all out.


Scott Shaver(Posted 2006) [#2]
you can't do that because incbin is a compile time operation not a runtime operation.

What you need is for BRL to add ?ifdef and ?def compiler directives.


Gabriel(Posted 2006) [#3]
Can't you just put all your incbin's in a module or include and then Import that ( not include it ) so that it won't be rebuilt unless modified?


Booticus(Posted 2006) [#4]
Wierd with the bmax 1.20 "update" that went south. :(


Gabriel(Posted 2006) [#5]
I'm guessing that it's always been south, it just never told you before. I think it was probably being IncBin'ed 100% of the time, regardless of any conditional or looping statements you buried it in.


Curtastic(Posted 2006) [#6]
thanks for the fast replies


you can't do that because incbin is a compile time operation not a runtime operation.


well so is "If True", right?
Like if you have "If False" the code in the if doesn't get compiled into the exe.


Can't you just put all your incbin's in a module or include and then Import that ( not include it ) so that it won't be rebuilt unless modified?


well the slowdown when I run the program is because each image needs to be packed into the new exe every time I run it from the IDE, thats why I have a const flag that takes off incbinning and loads images normally.
I unrem the Incbins and change the flag so it adds "incbin::" to the loadimage(). I do this every time I upload a new version of my RPG (its in my sig).


Gabriel(Posted 2006) [#7]
well the slowdown when I run the program is because each image needs to be packed into the new exe every time I run it from the IDE, thats why I have a const flag that takes off incbinning and loads images normally.


I know. If it's imported, it won't need to be packed though, will it? It should already be packed, and just appended to your program code which is recompiled every time.

I haven't tried this, but it seems logical.


ziggy(Posted 2006) [#8]
The best way to improve this building speed is,
create a resource.bmx file, that incbins all your media
then 'import' this file in your program

all the 'incbined' data in the resource.bmx is available from any bmx file in your application, but resource.bmx is only compiled when new media is added to it. (unless you disable the quickbuid)


Hambone(Posted 2006) [#9]
Does anyone know if a BMAX program that has incbin in it will work after being upx'ed?

Thanks,

Allan


Curtastic(Posted 2006) [#10]
thanks it works. but I still think my first example should work.


Brucey(Posted 2006) [#11]
Your first example is a runtime check for a variable.
The incbin file is inlined during compilation.

What you are saying is that you would like the compiler to be able to do runtime checking of the code at compile-time.
...which is perhaps a bit much for a compiler to be doing, really.

As Scott said, the best option would be for us to have some more compiler directives, to give us a bit more flexibility at compile-time.


popcade(Posted 2006) [#12]
If you 're doning with Win32 stuff only, you can try MoleBox, IncBin give you the method to work under Mac/Linux, there's also a way to make BMax loads media in plain zip


Dreamora(Posted 2006) [#13]
Incbin != molebox ... incbin does not protect your media in any way ... it just attaches them to the exe which is normally a bad idea (update wise). Using a seperate zip (encrypted) is the better idea.


popcade(Posted 2006) [#14]
Yes, I suggest you to use the ZipEngine by gman

I didn' mention MoleBox use same way to include medias, I just want to say it's an alternative way to do similar work.


Curtastic(Posted 2006) [#15]

Your first example is a runtime check for a variable.


I don't think the If exists in the EXE. There shouldnt be any runtime check, like "If incbinning Then" converts to "If True" which converts to ""...nothing, thennnnnn start incbinning my data :)


Russell(Posted 2006) [#16]
But Incbin is "read" by the compiler, and If is "read" during the running of the program.

A compiler directive, such as Purebasic's CompilerIf directive is what we need since this is not evaluated during run time, but during compile time.

It's a bit hard to grasp at first, I know.

Russell


kenshin(Posted 2006) [#17]
A complete set of conditional compile directive's would be nice. It's one of the things I'm missing from PB. I guess there's always the ?Debug directive if your really desperate.


Curtastic(Posted 2006) [#18]
Well in blitz3d if I have

If false then
;all the code in here is not even compiled into the exe.
endif

Therefore there is no if "read" during the running of the program, the code is just omitted. Blitzmax should do this also, but it seems to compile everything in for some reason.