A bug, presumably in the parser
If possible, could you write a small test case for the testframework that reproduces the bug? That would make it easier for me to find the error.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
I'm not very used to using mingw. I have installed it and msys. When I try to run make on one of the linux make files it gives me an error. Could you send me the makefile you use for building the library and let me know how to compile it with mingw?
I'll try to figure it out myself, but if you could just tell me it would be easier and faster. :)
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
[EDIT] But I am pretty sure that you could compile the code I provided under any standard compliant compiler, so there's no need for MinGW. But well, having GNU for Windows won't hurt you. Oh, and if you want to use makefiles with MinGW, you need to download this:
MingW32-Make
because the make that comes with the standard package is no good. [/EDIT]
OK, so I did manage to compile the library with MinGW. Now I'm trying to compile the testframework. But I haven't figured out how to do the linking. Any hints?
I have 3 object files and the angelscript library.
CPP = gccCCFLAGS =BIN = ../../bin/testframe.exebstr.o: ../../source/bstr.cpp $(CPP) -c ../../source/bstr.cpp -o bstr.o $(CXXFLAGS)main.o: ../../source/main.cpp $(CPP) -c ../../source/main.cpp -o main.o $(CXXFLAGS)test_build.o: ../../source/test_build.cpp $(CPP) -c ../../source/test_build.cpp -o test_build.o $(CXXFLAGS)OBJS = bstr.o main.o test_build.o all: $(BIN)$(BIN): $(OBJS) ld -dn -o $(BIN) $(OBJS) ../../lib/libangelscript.a.cpp.o: $(CPP) $(CCFLAGS) -c $< -o $@clean: rm -f *.o *~ $(BIN)
When linking there are a lot of missing functions (_mainCRTStartUp, memcpy, etc). I think I need to link with the default libraries, but I'm not yet sure how. Can you show me?
I should learn to use MinGW, because it will allow me check portability issues on at least two compilers.
Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
I link the program with
g++ -o $(BIN) $(OBJS) ../../lib/libangelscript.a
I also found the problem. It is an assertion error that makes the program bail out. Somewhere a temporary variable isn't correctly cleaned up when the function name isn't found. I'll find the bug as soon as possible.
I didn't find the problem on MSVC because I forgot that I using the release version of the library ;)
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
CXX = g++CXXFLAGS =BIN = ../../bin/testframe.exeOBJS = bstr.o main.o test_build.o all: $(BIN)bstr.o: main.o: test_build.o: $(BIN): $(OBJS) $(CXX) $(CXXFLAGS) $(OBJS) -o $(BIN) -langelscriptclean: rm -f *.o *~ $(BIN) .PHONY: clean
Some things I changed and why:
1. CXX should be g++. g++ is the C++ compiler, gcc is the C compiler. You can tell gcc to compile c++ code, but it's not worth the effort.
2. Don't link directly with the .a, use the -l switch together with the name of your libfile. For you, it'll be "-langelscript". For this, you have to copy your .a file to the "mingw/lib/" directory or specify an additional library directory with the "-L" switch.
3. You don't have to specify that the object depends on its own source code (the parts you had after the colons). And you don't have to tell make to use CXX for the .cpp files, as long as you set the cxx variable. [EDIT]Haven't seen the project, but you probably need to add some headers to the dependency lists. I'm pretty sure your main.cpp depends on both bstr.h and test_build.h, right?[/EDIT]
4. It's possible to use ld directly, but most of the time you use g++ for linking also. That's because the g++ (and gcc) compiler does the linking by default. To tell it NOT to do the linking of an executable, you need to specify -c.
Whew, that's all. Look at me, I'm teaching the almighty library developer :P. But seriously, you should read some tut on makefile's and gnu compilers to quickly get the hang of it.
I found the bug-fix for you:
The assert() in asCCompiler::CompileStatementBlock() should only be done if there is no compiler errors. So change line 349 in as_compiler.cpp to:
if( !hasCompileErrors ) assert(tempVariables.GetLength() == 0);
Thanks for the help.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
I'm feeling like contributing something to your library now (for your dedication and time and so on ;). Maybe you would be interested in having a dedicated MinGW makefile, with standard interface. Standard interface, meaning that typing:
make
make install
Does all the job. "make" creates the lib, and "make install" copies the library and include files to respective directiores under MinGW. Just tell me if you want that makefile and I'll provide it in no-time ;). (Oh, and also, remember to include the empty "lib" directory in the next distribution of your library, so that all those different makes don't choke on it. And put a "delete.me" or something file in it, so it won't get lost when unarchiving, some unarchivers ommit empty dirs).