About Monkey 2 › Forums › Monkey 2 Programming Help › Setting Field declarations to Null
This topic contains 5 replies, has 3 voices, and was last updated by
Arjailer
2 years, 1 month ago.
-
AuthorPosts
-
February 20, 2017 at 3:22 pm #7238
By habit (years of C#) I set Field declarations to Null, eg:
Monkey1Field dungeonConstructorState:DungeonConstructorState = NullBut doing this often leads to compile errors like:
Monkey123456789101112131415161718192021222324252627282930313233343536Mx2cc version 1.1.03***** Building app 'C:/Documents/Development Projects/Monkey 2/Dungeon/dungeon.monkey2' *****Parsing...Semanting...Translating...Compiling...Build error: System command 'g++ -I"C:/Documents/Programs/Monkey2/monkey2-master/modules/" -I"C:/Documents/Programs/Monkey2/monkey2-master/modules/monkey/native" -I"C:/Documents/Development Projects/Monkey 2/Dungeon/" -std=c++11 -m32 -I"C:/Documents/Programs/Monkey2/monkey2-master/modules/freetype/freetype-2.6.3/include/" -I"C:/Documents/Programs/Monkey2/monkey2-master/modules/openal/openal-soft/include/" -I"C:/Documents/Programs/Monkey2/monkey2-master/modules/gles20/angle/include/" -I"C:/Documents/Programs/Monkey2/monkey2-master/modules/sdl2/SDL/include/" -DBB_REFLECTION -c -o "C:/Documents/Development Projects/Monkey 2/Dungeon/dungeon.buildv1.1.03/windows_debug/build/_1src_2dungeon_0game_02worlds_02environments_02environmentconstructorfactory.cpp.o" "C:/Documents/Development Projects/Monkey 2/Dungeon/dungeon.buildv1.1.03/windows_debug/src/dungeon_game_2worlds_2environments_2environmentconstructorfactory.cpp"' failed.g++ -I"C:/Documents/Programs/Monkey2/monkey2-master/modules/" -I"C:/Documents/Programs/Monkey2/monkey2-master/modules/monkey/native" -I"C:/Documents/Development Projects/Monkey 2/Dungeon/" -std=c++11 -m32 -I"C:/Documents/Programs/Monkey2/monkey2-master/modules/freetype/freetype-2.6.3/include/" -I"C:/Documents/Programs/Monkey2/monkey2-master/modules/openal/openal-soft/include/" -I"C:/Documents/Programs/Monkey2/monkey2-master/modules/gles20/angle/include/" -I"C:/Documents/Programs/Monkey2/monkey2-master/modules/sdl2/SDL/include/" -DBB_REFLECTION -c -o "C:/Documents/Development Projects/Monkey 2/Dungeon/dungeon.buildv1.1.03/windows_debug/build/_1src_2dungeon_0game_02worlds_02environments_02environmentconstructorfactory.cpp.o" "C:/Documents/Development Projects/Monkey 2/Dungeon/dungeon.buildv1.1.03/windows_debug/src/dungeon_game_2worlds_2environments_2environmentconstructorfactory.cpp"In file included from C:/Documents/Programs/Monkey2/monkey2-master/modules/monkey/native/bbmonkey.h:12:0,from C:/Documents/Development Projects/Monkey 2/Dungeon/dungeon.buildv1.1.03/windows_debug/include/dungeon_game_2worlds_2environments_2environmentconstructorfactory.h:5,from C:/Documents/Development Projects/Monkey 2/Dungeon/dungeon.buildv1.1.03/windows_debug/src/dungeon_game_2worlds_2environments_2environmentconstructorfactory.cpp:2:C:/Documents/Programs/Monkey2/monkey2-master/modules/monkey/native/bbgc.h: In instantiation of 'void bbGCVar<T>::enqueue() [with T = t_game_worlds_environments_dungeon_DungeonConstructorState]':C:/Documents/Programs/Monkey2/monkey2-master/modules/monkey/native/bbgc.h:233:10: required from 'bbGCVar<T>::bbGCVar(T*) [with T = t_game_worlds_environments_dungeon_DungeonConstructorState]'C:/Documents/Development Projects/Monkey 2/Dungeon/dungeon.buildv1.1.03/windows_debug/include/dungeon_game_2worlds_2environments_2dungeon_2dungeonconstructor.h:37:160: required from hereC:/Documents/Programs/Monkey2/monkey2-master/modules/monkey/native/bbgc.h:225:16: error: cannot dynamic_cast '((bbGCVar<t_game_worlds_environments_dungeon_DungeonConstructorState>*)this)->bbGCVar<t_game_worlds_environments_dungeon_DungeonConstructorState>::_ptr' (of type 'struct t_game_worlds_environments_dungeon_DungeonConstructorState*') to type 'struct bbGCNode*' (source is a pointer to incomplete type)bbGC::enqueue( dynamic_cast<bbGCNode*>( _ptr ) );^***** Fatal mx2cc error *****Internal mx2cc build errorAnyone have any idea why this would be?
It only affects Field declarations (Local and method parameter declarations seem to be fine being set to Null), and it doesn’t happen every time I add the “= Null“, and if I remove the “= Null” then it works as expected, so it’s not a big deal, but it keeps tripping me up (habits are hard to break) and it seems odd that it would happen.
February 20, 2017 at 4:25 pm #72391. Today or yesterday Mark fixed something like that bug. Try to use newest develop sources.
2. Fields initialized with default values automatically. Not need to write =Null for objects types or =0 for int.
February 20, 2017 at 4:32 pm #7240- I checked the repo before posting and it didn’t look like anything had changed in the last few weeks. I’ll give it a try in the morning though.
- Yeah, but it shouldn’t fail if you do
February 20, 2017 at 4:41 pm #7241Hm. There is only merged patch in the repository. Then waiting for the guru.
February 20, 2017 at 11:39 pm #7245Fix for this is now up in develop branch.
You’ll need to updatemx2cc though.
February 21, 2017 at 3:20 pm #7248Thanks Mark – works fine now – my ingrained habits can continue
-
AuthorPosts
You must be logged in to reply to this topic.