IncFile() and IncArray() macros [Updated 22-1-2009]
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
Incfile.bi is provided in this thread. But it sounds like the contents of your header file are actually that of an executable file. (They begin with "MZ".)
This could be due to a botched fbc command; or because you've tried to overwrite the file yourself, maybe under the impression that it's the .bi file itself that gets stored in your program; or because of some mysterious other reason I can't think of at the moment.
Try resaving incfile.bi with the contents provided in this thread, and try again. If that doesn't work, then I'm afraid I don't know. I haven't looked at this code in any depth recently...
This could be due to a botched fbc command; or because you've tried to overwrite the file yourself, maybe under the impression that it's the .bi file itself that gets stored in your program; or because of some mysterious other reason I can't think of at the moment.
Try resaving incfile.bi with the contents provided in this thread, and try again. If that doesn't work, then I'm afraid I don't know. I haven't looked at this code in any depth recently...
Re: IncFile() and IncArray() macros [Updated 6-10-2008]
Ok counting_pine, so just to clarify incfile.bi is in this thread and not as the following?
[quote= voodooattack
incfile.bi
[/quote]
because as i said, i compiled this code and made it .bi not .exe (as i thought that was how we were supposed to use it), not that I'm sure of how the actual embedding at compile-time works or is done either.
Thanks!
[quote= voodooattack
incfile.bi
Code: Select all
#IFNDEF INCFILE_BI
#DEFINE INCFILE_BI
#MACRO IncFileEx(label, file, sectionName, attr)
#if __FUNCTION__ <> "__FB_MAINPROC__"
Dim label As Const Ubyte Ptr = Any
Dim label##_len As Uinteger = Any
#if __FB_DEBUG__
asm jmp .LT_END_OF_FILE_##label##_DEBUG_JMP
#else
' Switch to/Create the specified section
#if attr = ""
asm .section sectionName
#else
asm .section sectionName, attr
#endif
#endif
' Assign a label to the beginning of the file
asm .LT_START_OF_FILE_##label#:
asm __##label##__start = .
' Include the file
asm .incbin ##file
' Mark the end of the the file
asm __##label##__len = . - __##label##__start
asm .LT_END_OF_FILE_##label:
' Pad it with a NULL Integer (harmless, yet useful for text files)
asm .LONG 0
#if __FB_DEBUG__
asm .LT_END_OF_FILE_##label##_DEBUG_JMP:
#else
' Switch back to the .text (code) section
asm .section .text
asm .balign 16
#endif
asm .LT_SKIP_FILE_##label:
asm mov dword ptr [label], offset .LT_START_OF_FILE_##label#
asm mov dword ptr [label##_len], offset __##label##__len
#else
Extern "c"
Extern label As Ubyte Ptr
Extern label##_len As Uinteger
End Extern
#if __FB_DEBUG__
asm jmp .LT_END_OF_FILE_##label##_DEBUG_JMP
#else
' Switch to/create the specified section
#if attr = ""
asm .section sectionName
#else
asm .section sectionName, attr
#endif
#endif
' Assign a label to the beginning of the file
asm .LT_START_OF_FILE_##label#:
asm __##label##__start = .
' Include the file
asm .incbin ##file
' Mark the end of the the file
asm __##label##__len = . - __##label##__start
asm .LT_END_OF_FILE_##label:
' Pad it with a NULL Integer (harmless, yet useful for text files)
asm .LONG 0
asm label:
asm .int .LT_START_OF_FILE_##label#
asm label##_len:
asm .int __##label##__len
#if __FB_DEBUG__
asm .LT_END_OF_FILE_##label##_DEBUG_JMP:
#else
' Switch back to the .text (code) section
asm .section .text
asm .balign 16
#endif
asm .LT_SKIP_FILE_##label:
#endif
#endmacro
#macro IncFile(label, file)
IncFileEx(label, file, .data, "") 'Use the .data (storage) section (SHARED)
#endmacro
#endif
because as i said, i compiled this code and made it .bi not .exe (as i thought that was how we were supposed to use it), not that I'm sure of how the actual embedding at compile-time works or is done either.
Thanks!
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
There is no "original" copy: grab the text from here and save it wherever you like, as long as FB can find it when you #include it.
I think we may be on different wavelengths here though, so if you have any further problems, you're going to have to give some background on what you've done and what you're trying to achieve.
EDIT: re-reading your first post, it looks like you're *compiling* the text provided, and naming the resulting executable as incfile.bi.
Don't compile the text, just save it directly.
".bi" header files are just text files containing BASIC code. They're a handy way to store definitions like function declares, constants and macros where they won't clutter up your program's code. #include pretty much just takes the text from the .bi file and acts like you'd pasted the whole thing in instead of just giving it the #include line.
I think we may be on different wavelengths here though, so if you have any further problems, you're going to have to give some background on what you've done and what you're trying to achieve.
EDIT: re-reading your first post, it looks like you're *compiling* the text provided, and naming the resulting executable as incfile.bi.
Don't compile the text, just save it directly.
".bi" header files are just text files containing BASIC code. They're a handy way to store definitions like function declares, constants and macros where they won't clutter up your program's code. #include pretty much just takes the text from the .bi file and acts like you'd pasted the whole thing in instead of just giving it the #include line.
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
-
- Posts: 605
- Joined: Feb 18, 2006 13:30
- Location: Alexandria / Egypt
- Contact:
Fixed, thanks for bringing this up, looks like something changed in the compiler.toneboy wrote:I am receiving and error saying:
E:\FBIDETEMP.asm: Assembler messages:
E:\FBIDETEMP.asm:107: Error: non-constant expression in ".if"
To do with a macro IncArrayEx().
Any tips?
Thanks a lot
Macro updated, please copy it again from the first post (only supports byte arrays now).