I recently decided that I would move a bunch of my file handling functions off to a DLL to more easily share it later. Somewhere in the process of doing so, my code has stopped compiling. The error goes something like this.
C:\Users\Pokeman2003\Desktop\Project>"compfb\fbc64.exe" -v -exx -x ProjMan.exe -eassert -O 0 -R -edebuginfo Project\main.bas
FreeBASIC Compiler - Version 1.09.0 (2021-12-31), built for win64 (64bit)
Copyright (C) 2004-2021 The FreeBASIC development team.
standalone
target: win64, x86-64, 64bit
backend: gcc
compiling: Project\main.bas -o Project\main.c (main module)
Now compiling main.bas
Now compiling shared\cmacros.bas
WARNING SERIES NOT DEFINED!
WARNING COMPILE TIME NOT DEFINED!
Now compiling shared\errhand.bas
Including \filehandling\...
Now compiling /shared/fdf.bi
Now compiling shared\filehandling\setup.bas
Settings Loader(2) error 61: Illegal inside functions in 'sub loadsetup()'
Now compiling shared\prompt.bas
Prompt Handling(1) error 61: Illegal inside functions in 'function promptchoice(choicelist as zstring) as ubyte'
Project\main.bas(10) error 42: Variable not declared, loadsetup in 'loadsetup()'
Project\main.bas(11) error 61: Illegal inside functions, found 'shared' in 'dim shared state as ubyte = 0'
State Handler(8) error 42: Variable not declared, promptchoice in 'chosen = promptchoice("lpre")'
State Handler(22) error 126: Expected 'END FUNCTION' in 'errhandle'
This WILL compile if you remove loadsetup() and the include for filehandling\include.bas, so I don't understand what's gone wrong here.
Here's the source code, and a copy of the DLL.
badidea wrote: ↑Mar 31, 2022 19:20
The variable 'file' does not exist in loadsetup()
Semi intentional, it was an attempted fix to the problem I forgot to revert. I, while sleep deprived, remembered the goto command having this issue in the past and to fix it, you just DIM'd everything outside of the goto command.
Of course, it fixed nothing, as most of my sleep deprived escapades happen to not do.
Put your fdf.dll in the same folder as main.bas
Your fdf.bi should be
#print Now compiling /shared/fdf.bi
#inclib "fdf"
declare function openfdf(filename as zstring) as ubyte 'Open a file.
Your setup.bas should be
#PRINT Now compiling shared\filehandling\setup.bas
#line 0 "Settings Loader"
'dim file as ubyte
sub loadsetup()
print "Loading..."
var file = openfdf("settings")
end sub
Dodicat, with all due respect, how would that change anything? I decided to try it anyways, and as I expected, it changed literally nothing, so unless I've missed something, this isn't a fix at all.
Now compiling main.bas
Now compiling shared\cmacros.bas
WARNING SERIES NOT DEFINED!
WARNING COMPILE TIME NOT DEFINED!
Now compiling shared\errhand.bas
Including \filehandling\...
Now compiling /shared/fdf.bi
Now compiling shared\filehandling\setup.bas
Settings Loader(2) error 61: Illegal inside functions in 'sub loadsetup()'
Now compiling shared\prompt.bas
Prompt Handling(1) error 61: Illegal inside functions in 'function promptchoice(choicelist as zstring) as ubyte'
main.bas(10) error 42: Variable not declared, loadsetup in 'loadsetup()'
main.bas(11) error 61: Illegal inside functions, found 'shared' in 'dim shared state as ubyte = 0'
State Handler(8) error 42: Variable not declared, promptchoice in 'chosen = promptchoice("lpre")'
State Handler(22) error 126: Expected 'END FUNCTION' in 'errhandle'
Compiler output:
Now compiling main.bas
Now compiling shared\cmacros.bas
WARNING SERIES NOT DEFINED!
WARNING COMPILE TIME NOT DEFINED!
Now compiling shared\errhand.bas
Including \filehandling\...
Now compiling /shared/fdf.bi
Now compiling shared\filehandling\setup.bas
Now compiling shared\prompt.bas
I want to apologize dodicat, you were right. The fixes did work. I applied the two code fixes to the wrong source code copy on my hard drive, so I was really only applying the copying the dll into my source code fix. I'll soon update the thread with the fix information, but I'm exhausted right now.
Again, really, I'm sorry.