C++ build errors

Community Forums/Monkey2 Talk/C++ build errors

Danilo(Posted 2016) [#1]
From MonkeyX topic:
http://www.monkey-x.com/Community/posts.php?topic=10515

MX2 does not catch it currently, and I get C++ build errors on Mac OS X:
Translating...
Compiling....
Build error: System command 'g++ -std=c++11 -g -std=c++11 [...] failed.
[...] new_new.cpp:2:
In file included from [...]/new_new.h:9:
[...]/monkey_types.h:12:1: warning: null character ignored [-Wnull-character]
^
In file included from [...]/new_new.cpp:2:
[...]/new_new.h:38:1: warning: null character ignored [-Wnull-character]
^
[...]/new.buildv003/build_cache/desktop_debug_macos/new_new.cpp:51:1: warning: null character ignored [-Wnull-character]
^
In file included from [...]/new_new.cpp:2:
In file included from [...]/new_new.h:5:
In file included from [...]/monkey2/modules/monkey/native/bbmonkey.h:10:
In file included from [...]/monkey2/modules/monkey/native/bbassert.h:5:
[...]/monkey2/modules/monkey/native/bbobject.h:63:11: error: no matching constructor for initialization of 't_default_EntityA'
        T *p=new T( a... );


Test codes:
Class Entity
	Field name:String = "entity"
	
	Method New()
	End

	Method New( name:String )
		Self.name = name
	End
End

Class EntityA Extends Entity
End

Function Main()
	Local a := New EntityA
	Local b := New EntityA( "Entity Name" )
	
	Print a.name
	Print b.name
End


Class Entity
	Field name:String

	Method New( name:String = "entity" )
		Self.name = name
	End
End

Class EntityA Extends Entity
End

Function Main()
	Local a := New EntityA
	Local b := New EntityA( "Entity Name" )
	
	Print a.name
	Print b.name
End



dawlane(Posted 2016) [#2]
Under Linux with g++ 4.8.4 I get
In file included from /home/jason/applications/monkey2/tests/mytest/d1.buildv003/build_cache/desktop_release_linux/d1_d1.cpp:2:0:
/home/jason/applications/monkey2/tests/mytest/d1.buildv003/build_cache/desktop_release_linux/d1_d1.h:39:1: warning: null character(s) ignored [enabled by default]
/home/jason/applications/monkey2/tests/mytest/d1.buildv003/build_cache/desktop_release_linux/d1_d1.cpp:37:1: warning: null character(s) ignored [enabled by default]
In file included from /home/jason/applications/monkey2/modules/monkey/native/bbassert.h:5:0,
                 from /home/jason/applications/monkey2/modules/monkey/native/bbmonkey.h:10,
                 from /home/jason/applications/monkey2/tests/mytest/d1.buildv003/build_cache/desktop_release_linux/d1_d1.h:5,
                 from /home/jason/applications/monkey2/tests/mytest/d1.buildv003/build_cache/desktop_release_linux/d1_d1.cpp:2:
/home/jason/applications/monkey2/modules/monkey/native/bbobject.h: In instantiation of T* bbGCNew(A ...) [with T = t_default_EntityA; A = {bbString}]:
/home/jason/applications/monkey2/tests/mytest/d1.buildv003/build_cache/desktop_release_linux/d1_d1.cpp:20:51:   required from here
/home/jason/applications/monkey2/modules/monkey/native/bbobject.h:63:19: error: no matching function for call to t_default_EntityA::t_default_EntityA(bbString&)
  T *p=new T( a... );
                   ^
/home/jason/applications/monkey2/modules/monkey/native/bbobject.h:63:19: note: candidates are:
In file included from /home/jason/applications/monkey2/tests/mytest/d1.buildv003/build_cache/desktop_release_linux/d1_d1.cpp:2:0:
/home/jason/applications/monkey2/tests/mytest/d1.buildv003/build_cache/desktop_release_linux/d1_d1.h:34:3: note: t_default_EntityA::t_default_EntityA()
   t_default_EntityA(){
   ^
/home/jason/applications/monkey2/tests/mytest/d1.buildv003/build_cache/desktop_release_linux/d1_d1.h:34:3: note:   candidate expects 0 arguments, 1 provided
/home/jason/applications/monkey2/tests/mytest/d1.buildv003/build_cache/desktop_release_linux/d1_d1.h:30:8: note: t_default_EntityA::t_default_EntityA(const t_default_EntityA&)
 struct t_default_EntityA : public t_default_Entity{
        ^
/home/jason/applications/monkey2/tests/mytest/d1.buildv003/build_cache/desktop_release_linux/d1_d1.h:30:8: note:   no known conversion for argument 1 from bbString to const t_default_EntityA&
/home/jason/applications/monkey2/tests/mytest/d1.buildv003/build_cache/desktop_release_linux/d1_d1.h:30:8: note: t_default_EntityA::t_default_EntityA(t_default_EntityA&&)
/home/jason/applications/monkey2/tests/mytest/d1.buildv003/build_cache/desktop_release_linux/d1_d1.h:30:8: note:   no known conversion for argument 1 from bbString to t_default_EntityA&&
cc1plus: warning: unrecognized command line option "-Wno-parentheses-equality" [enabled by default]

I will see what it does with a new GCC version later.


Danilo(Posted 2016) [#3]
> I will see what it does with a new GCC version later.

You will see almost the same errors, because the problem is MX2 inheritance of constructors, and emiting correct code for it.