Garbage data output on operator+ member

Started by
16 comments, last by BrianEmpson 12 years, 8 months ago
Hey, thanks for the response. I tried to compile the test_feature project but I'm getting a ton of linker errors, even after recompiling the static library:



||=== codeblocks, Debug ===|
obj\Debug\source\main.o||In function `main':|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\main.cpp|192|undefined reference to `Test_Addon_ScriptHandle::Test()'|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\main.cpp|193|undefined reference to `TestDefaultArg::Test()'|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\main.cpp|194|undefined reference to `TestScriptRetRef::Test()'|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\main.cpp|195|undefined reference to `TestGarbageCollect::Test()'|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\main.cpp|196|undefined reference to `TestFunctionPtr::Test()'|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\main.cpp|197|undefined reference to `TestModule::Test()'|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\main.cpp|198|undefined reference to `TestGetSet::Test()'|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\main.cpp|199|undefined reference to `Test_Addon_ScriptArray::Test()'|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\main.cpp|200|undefined reference to `TestOperator::Test()'|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\main.cpp|304|undefined reference to `TestCDeclReturn::Test()'|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\main.cpp|316|undefined reference to `TestCDecl_ClassK()'|
obj\Debug\source\test_any.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_any.cpp|111|undefined reference to `RegisterScriptString_Generic(asIScriptEngine*)'|
obj\Debug\source\test_any.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_any.cpp|142|undefined reference to `RegisterScriptString_Generic(asIScriptEngine*)'|
obj\Debug\source\test_any.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_any.cpp|182|undefined reference to `RegisterScriptString_Generic(asIScriptEngine*)'|
obj\Debug\source\test_any.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_any.cpp|209|undefined reference to `RegisterScriptString_Generic(asIScriptEngine*)'|
obj\Debug\source\test_any.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_any.cpp|263|undefined reference to `CScriptString::Release() const'|
obj\Debug\source\test_argref.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_argref.cpp|43|undefined reference to `RegisterScriptString_Generic(asIScriptEngine*)'|
obj\Debug\source\test_array.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_array.cpp|156|undefined reference to `RegisterScriptString_Generic(asIScriptEngine*)'|
obj\Debug\source\test_arrayhandle.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_arrayhandle.cpp|56|undefined reference to `RegisterScriptString_Generic(asIScriptEngine*)'|
obj\Debug\source\test_arrayintf.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_arrayintf.cpp|35|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_autohandle.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_autohandle.cpp|73|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_autohandle.o||In function `A':|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_autohandle.cpp|43|undefined reference to `CScriptString::CScriptString()'|
obj\Debug\source\test_autohandle.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_autohandle.cpp|109|undefined reference to `CScriptString::Release() const'|
obj\Debug\source\test_autohandle.o||In function `~A':|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_autohandle.cpp|47|undefined reference to `CScriptString::Release() const'|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_autohandle.cpp|47|undefined reference to `CScriptString::Release() const'|
obj\Debug\source\test_autohandle.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_autohandle.cpp|31|undefined reference to `CScriptString::CScriptString()'|
obj\Debug\source\test_autohandle.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_autohandle.cpp|24|undefined reference to `CScriptString::Release() const'|
obj\Debug\source\test_autohandle.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_autohandle.cpp|15|undefined reference to `CScriptString::Release() const'|
obj\Debug\source\test_bits.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_bits.cpp|82|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_bool.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_bool.cpp|221|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_castop.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_castop.cpp|76|undefined reference to `CScriptString::CScriptString(std::string const&)'|
obj\Debug\source\test_castop.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_castop.cpp|175|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_compiler.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_compiler.cpp|1822|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_compiler.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_compiler.cpp|1856|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_compiler.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_compiler.cpp|266|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_compiler.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_compiler.cpp|680|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_compiler.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_compiler.cpp|706|undefined reference to `RegisterScriptString_Generic(asIScriptEngine*)'|
obj\Debug\source\test_compiler.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_compiler.cpp|773|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_compiler.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_compiler.cpp|807|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_compiler.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_compiler.cpp|869|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_compiler.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_compiler.cpp|1070|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_compiler.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_compiler.cpp|1193|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_condition.o||In function `formatUI':|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_condition.cpp|55|undefined reference to `CScriptString::CScriptString(std::string const&)'|
obj\Debug\source\test_condition.o||In function `formatf':|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_condition.cpp|47|undefined reference to `CScriptString::CScriptString(std::string const&)'|
obj\Debug\source\test_condition.o||In function `Z13TestConditionv':|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_condition.cpp|70|undefined reference to `CScriptString::CScriptString()'|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_condition.cpp|74|undefined reference to `RegisterScriptString_Generic(asIScriptEngine*)'|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_condition.cpp|163|undefined reference to `CScriptString::Release() const'|
obj\Debug\source\test_constobject.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_constobject.cpp|109|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
obj\Debug\source\test_constructor.o||In function `Z15TestConstructorv':|
E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_constructor.cpp|77|undefined reference to `RegisterScriptString_Generic(asIScriptEngine*)'|
obj\Debug\source\test_debug.o:E:\pb\angelscript_2.21.0\sdk\tests\test_feature\source\test_debug.cpp|281|undefined reference to `RegisterScriptString(asIScriptEngine*)'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===|



Working on getting the test_feature codeblocks project to link. I noticed it complained about some files being missing from the project. scriptstring and a few bstr.cpp files I think it was.
Advertisement
I originally had Microsoft Visual C++ 2010 when I started C++, I will switch back and see what difference it makes...
The project files is probably very outdated. You need to add all the source files in the /tests/test_features/source + all the source files for the add-ons to the project in order to make it compile.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Certain functions I cannot find in any of the source files. Is everything there in the tests source?
My results:



TestVirtualInheritance: GNUC: AngelScript cannot detect virtual inheritance thus
this test doesn't apply
-- TestVirtualInheritance passed
-- TestStdcall4Args passed
-- TestNotComplexStdcall passed
---------
MEMORY STATISTICS
number of allocations : 351978
max allocated memory at any one time : 160916
max number of simultaneous allocations: 2519
total amount of allocated memory : 36187731
medium size of allocations : 102
--------------------------------------------
All of the tests passed with success.

Press any key to quit.

In visual studio 2010 the script executes as it should. So it happens only when I compile using CodeBlocks...is there anything I can do to patch it?

EDIT: I've spent the last few hours attempting to plug in defines in as_config.h and nothing seems to work so far. What would be set incorrectly in as_config.h?
Since all the tests in test_feature passed and your code works with msvc this can only mean that there is something in particular with dimension2d that makes mingw treat it differently.

As this is a new scenario I think I'll have to install code::blocks myself in order to figure out what it is that makes this class unique.

I'll try to find the time to do it this weekend and I'll let you know how it goes.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

The dimension2d class is from the free graphics API Irrlicht 1.7:

http://irrlicht.sourceforge.net/index.html

http://irrlicht.sourceforge.net/docu/index.html

Thank you for your help.
I figured it out. It wasn't a bug after all.

Despite the dimension2d template having what appears to be a copy constructor and assignment operator, the C++ compiler is not considering them as such because they are not explicitly declared with the type name. For this reason this type must be registered with the flag asOBJ_APP_CLASS_C and not asOBJ_APP_CLASS_CAK.

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 have confirmed this to work:

Video resolution: 800x600

Video resolution: 800x600

Total resolution: 1600x1200

Total resolution: 800x600

So, I should double check the type class parameter next time. Thank you so much!!

This topic is closed to new replies.

Advertisement